﻿Imports System.Net
Imports System.IO
Imports System.Xml
Imports Microsoft.VisualBasic.FileIO
Imports System.Collections.Specialized
Imports System.Text
Imports System.IO.Path
Imports System.Environment
Imports Microsoft.VisualBasic.Devices
Imports System.Management
Imports Microsoft.Win32
Imports System.Net.Sockets
Imports System.Drawing.Icon
Public Class Form1
    Dim steam As String
    Dim rutaarma As String
    Dim mpmision As String
    Dim esusservera3 As String
    Dim perfilpordefecto As String
    Dim esusbasico As String
    Dim esusconfig As String
    Dim misionespordefecto As String
    Dim crearperfil As System.IO.FileStream
    Dim crearperfil2 As System.IO.FileStream
    Dim creadordificultad As System.IO.FileStream
    Dim crearmod As System.IO.FileStream
    Dim crearprioridad As System.IO.FileStream
    Dim mision As System.IO.FileStream
    Dim puertost As System.IO.FileStream
    Dim exearma3server As String
    Dim carpetausuario As String
    Dim carpetauser As String
    Dim exearma3 As String
    Dim puerto As String
    Dim txtpuerto As String = "puerto.txt"
    Dim core1 As Integer
    Dim core2 As Integer
    Dim core3 As Integer
    Dim core4 As Integer
    Dim core5 As Integer
    Dim core6 As Integer
    Dim core7 As Integer
    Dim core8 As Integer
    Dim dificultad As String
    Dim addon As String = "mods.txt"
    Dim prioridad As String = "mods.prioridad.txt"
    Dim mods As String
    Dim prioridadmods As String
    Dim ram As Integer
    Dim variable As String
    Dim misionchecked As String
    Dim usuario As String
    Dim perfilcambiante As String
    Dim carpetausercambiante As String
    Dim carpetausuariocambiante As String
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        steam = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam", "InstallPath", Nothing)
        usuario = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Bohemia Interactive\Arma 3", "Player Name", Nothing)
        rutaarma = steam & "\steamapps\common\Arma 3"
        exearma3server = rutaarma & "\arma3server.exe"
        exearma3 = rutaarma & "\arma3.exe"
        TextBox3.Text = exearma3server
        TextBox4.Text = exearma3
        steam = steam & "\Steam.exe"
        mpmision = rutaarma & "\MPMissions"
        esusservera3 = rutaarma & "\EsusServerA3"
        perfilpordefecto = esusservera3 & "\PorDefecto"
        carpetauser = perfilpordefecto & "\Users"
        carpetausuario = carpetauser & "\" & usuario
        puerto = Combine(perfilpordefecto, txtpuerto)
        Try
            perfilcambiante = esusservera3 & "\" & ComboBox1.SelectedItem.ToString
        Catch ex As Exception

        End Try
        esusbasico = Combine(perfilpordefecto, "Esus_basico.cfg")
        esusconfig = Combine(perfilpordefecto, "Esus_config.cfg")
        dificultad = Combine(carpetausuario, usuario & ".Arma3Profile")
        variable = dificultad
        mods = Combine(perfilpordefecto, addon)
        prioridadmods = Combine(perfilpordefecto, prioridad)


        If (Not System.IO.Directory.Exists(esusservera3)) Then
            System.IO.Directory.CreateDirectory(esusservera3)
            System.IO.Directory.CreateDirectory(perfilpordefecto)
            System.IO.Directory.CreateDirectory(carpetauser)
            System.IO.Directory.CreateDirectory(carpetausuario)
        End If
        If (Not System.IO.File.Exists(mods)) Then
            crearmod = File.Create(mods)
            crearmod.Close()
            crearmod.Dispose()
        End If
        If (Not System.IO.File.Exists(prioridadmods)) Then
            crearprioridad = File.Create(prioridadmods)
            crearmod.Close()
            crearmod.Dispose()
        End If
        If (Not System.IO.File.Exists(esusbasico)) Then
            crearperfil = File.Create(esusbasico)
            crearperfil.Close()
            crearperfil.Dispose()
            puertost = System.IO.File.Create(puerto)
            puertost.Close()
            puertost.Dispose()
        End If
        If (Not System.IO.File.Exists(dificultad)) Then
            creadordificultad = File.Create(dificultad)
            creadordificultad.Close()
            Call creardificultad()
        End If
        If (Not System.IO.File.Exists(esusconfig)) Then
            crearperfil2 = File.Create(esusconfig)
            crearperfil2.Close()
            crearperfil2.Dispose()
        End If
        For Each folder In System.IO.Directory.GetDirectories(rutaarma, "@*")
            CheckedListBox1.Items.Add(Path.GetFileName(folder))
        Next
        For Each File In System.IO.Directory.GetFiles(mpmision, "*.pbo")
            CheckedListBox2.Items.Add(Path.GetFileName(File))
        Next
        For Each perfiles As String In My.Computer.FileSystem.GetDirectories _
       (esusservera3)
            ComboBox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension(perfiles))
        Next
        For Each obj In CheckedListBox2.Items
            Dim entre As Integer = obj.IndexOf(".")
            Dim mapas As String = obj.Substring(entre + 1, obj.IndexOf(".", entre + 1) - entre - 1)
            ComboBox2.Items.Add(mapas)
        Next
        borrarmapasduplicados()
        CheckedListBox3.Visible = False
        CheckedListBox2.Visible = True
        TextBox68.Text = CheckedListBox1.Items.Count
        TextBox65.Text = CheckedListBox2.Items.Count
        TextBox67.Text = CheckedListBox1.CheckedItems.Count
        TextBox66.Text = CheckedListBox2.CheckedItems.Count
        ComboBox1.SelectedItem = "PorDefecto"
        ComboBox4.SelectedIndex = 0
        ComboBox5.SelectedIndex = 0
        ComboBox6.SelectedIndex = 0
        ComboBox3.SelectedIndex = 0
        ComboBox7.SelectedIndex = 0



        If CheckBox2.Checked = True Then
            Label22.Visible = False
            NumericUpDown7.Visible = False
        Else
            Label22.Visible = True
            NumericUpDown7.Visible = True
        End If
        Call informacion()
        Try
            Dim fileReader As System.IO.StreamReader
            fileReader = My.Computer.FileSystem.OpenTextFileReader(puerto)
            Dim stringReader As String
            stringReader = fileReader.ReadLine()
            TextBox45.Text = stringReader
            fileReader.Close()
        Catch ex As Exception
        End Try
        Call leermods()
        Call leerdificultad()
        Call leerperfilbasico()
        Call leerperfilconfig()
        TextBox43.Text = System.Text.RegularExpressions.Regex.Replace(TextBox43.Text, "\s{2,}", " ")
        TextBox39.Text = TextBox39.Text.Replace(" ", "")
        TextBox38.Text = TextBox38.Text.Replace(" ", "")
        TextBox37.Text = TextBox37.Text.Replace(" ", "")
        TextBox36.Text = TextBox36.Text.Replace(" ", "")
        TextBox35.Text = TextBox35.Text.Replace(" ", "")
        TextBox34.Text = TextBox34.Text.Replace(" ", "")
        TextBox33.Text = TextBox33.Text.Replace(" ", "")
        TextBox21.Text = TextBox21.Text.Replace(" ", "")
        TextBox7.Text = TextBox7.Text.Replace(" ", "")
        TextBox8.Text = TextBox8.Text.Replace(" ", "")
        TextBox9.Text = TextBox9.Text.Replace(" ", "")
        TextBox10.Text = TextBox10.Text.Replace(" ", "")
        TextBox11.Text = TextBox11.Text.Replace(" ", "")
        TextBox12.Text = TextBox12.Text.Replace(" ", "")
        TextBox13.Text = TextBox13.Text.Replace(" ", "")
        TextBox14.Text = TextBox14.Text.Replace(" ", "")
        TextBox15.Text = TextBox15.Text.Replace(" ", "")
        Call hc()
    End Sub
    Sub hc()
        perfilcambiante = esusservera3 & "\" & ComboBox1.SelectedItem.ToString
        carpetausercambiante = perfilcambiante & "\" & "Users"
        carpetausuariocambiante = carpetausercambiante & "\" & usuario
        puerto = Combine(perfilcambiante, txtpuerto)
        esusbasico = Combine(perfilcambiante, "Esus_basico.cfg")
        esusconfig = Combine(perfilcambiante, "Esus_config.cfg")
        dificultad = Combine(carpetausuariocambiante, usuario & ".Arma3Profile")
        variable = dificultad
        Dim builder As New StringBuilder()
        For Each i As Object In ListBox2.Items
            i = i + ";"
            builder.Append(i.ToString())
        Next
        Dim parametros As String = Nothing
        If CheckBox3.Checked = True Then
            TextBox19.Text = "-connect=localhost" & " " & "-port=" & TextBox45.Text & " " & "-client -nosound" & " " & "-password=" & TextBox46.Text & " " & "-name=HC -profile=HC" & " " & "-mod=" & builder.ToString
        Else
            TextBox19.Text = "-connect=" & TextBox63.Text & " " & "-port=" & TextBox18.Text & " " & "-client -nosound" & " " & "-password=" & TextBox61.Text & " " & "-name=" & TextBox60.Text & " " & "-profile=" & TextBox60.Text & " " & "-mod=" & builder.ToString
        End If
        If CheckBox15.Checked = True Then
            TextBox60.Visible = True
            TextBox62.Visible = True
            TextBox63.Visible = True
            TextBox18.Visible = True
            TextBox61.Visible = True
            Label64.Visible = True
            Label65.Visible = True
            Label66.Visible = True
            Label67.Visible = True
            Label84.Visible = True
            CheckBox3.Checked = True
        Else
            TextBox60.Visible = False
            TextBox62.Visible = False
            TextBox63.Visible = False
            TextBox18.Visible = False
            TextBox61.Visible = False
            Label64.Visible = False
            Label65.Visible = False
            Label66.Visible = False
            Label67.Visible = False
            Label84.Visible = False
            CheckBox3.Checked = False

        End If
    End Sub
    Sub leerdificultad()
        Try
            Dim treintayuno As String = System.IO.File.ReadAllLines(dificultad)(31)
            Dim treintaydos As String = System.IO.File.ReadAllLines(dificultad)(32)
            Dim treintaytres As String = System.IO.File.ReadAllLines(dificultad)(33)
            Dim treintaycuatro As String = System.IO.File.ReadAllLines(dificultad)(34)
            Dim cientrotreintaynueve As String = System.IO.File.ReadAllLines(dificultad)(139)
            treintayuno = Replace(treintayuno, "skillFriendly=", "")
            treintayuno = Replace(treintayuno, ";", "")
            treintaydos = Replace(treintaydos, "precisionFriendly=", "")
            treintaydos = Replace(treintaydos, ";", "")
            treintaytres = Replace(treintaytres, "skillEnemy=", "")
            treintaytres = Replace(treintaytres, ";", "")
            treintaycuatro = Replace(treintaycuatro, "precisionEnemy=", "")
            treintaycuatro = Replace(treintaycuatro, ";", "")
            treintayuno = System.Text.RegularExpressions.Regex.Replace(treintayuno, "\s{2,}", " ")
            treintaydos = System.Text.RegularExpressions.Regex.Replace(treintaydos, "\s{2,}", " ")
            treintaytres = System.Text.RegularExpressions.Regex.Replace(treintaytres, "\s{2,}", " ")
            treintaycuatro = System.Text.RegularExpressions.Regex.Replace(treintaycuatro, "\s{2,}", " ")
            TextBox52.Text = treintayuno
            TextBox51.Text = treintaydos
            TextBox50.Text = treintaytres
            TextBox49.Text = treintaycuatro
        Catch ex As Exception

        End Try


    End Sub

    Sub creardificultad()

        Dim aryText(139) As String
        Dim x As Integer
        aryText(0) = "class Difficulties"
        aryText(1) = "{"
        aryText(2) = "class Recruit"
        aryText(3) = "{"
        aryText(4) = "class Flags"
        aryText(5) = "{"
        aryText(6) = "3rdPersonView=1;"
        aryText(7) = "armor=1;"
        aryText(8) = "autoAim=0;"
        aryText(9) = "autoGuideAT=1;"
        aryText(10) = "autoSpot=1;"
        aryText(11) = "cameraShake=0;"
        aryText(12) = "clockIndicator=1;"
        aryText(13) = "deathMessages=1;"
        aryText(14) = "enemyTag=0;"
        aryText(15) = "friendlyTag=1;"
        aryText(16) = "hud=1;"
        aryText(17) = "hudGroupInfo=1"
        aryText(18) = "hudPerm=1;"
        aryText(19) = "hudWp=1;"
        aryText(20) = "hudWpPerm=1;"
        aryText(21) = "map=1;"
        aryText(22) = "netStats=1;"
        aryText(23) = "tracers=1;"
        aryText(24) = "ultraAI=0;"
        aryText(25) = "unlimitedSaves=1;"
        aryText(26) = "vonID=1;"
        aryText(27) = "weaponCursor=1;"
        aryText(28) = "ExtendetInfoType=1;"
        aryText(29) = "MineTag=1;"
        aryText(30) = "};"
        aryText(31) = "skillFriendly=0.6;"
        aryText(32) = "precisionFriendly=0.6;"
        aryText(33) = "skillEnemy=0.28;"
        aryText(34) = "precisionEnemy=0.28;"
        aryText(35) = "};"
        aryText(36) = "class Regular"
        aryText(37) = "{"
        aryText(38) = "class Flags"
        aryText(39) = "{"
        aryText(40) = "3rdPersonView=1;"
        aryText(41) = "armor=0;"
        aryText(42) = "autoAim=0;"
        aryText(43) = "autoGuideAT=0;"
        aryText(44) = "autoSpot=0;"
        aryText(45) = "cameraShake=1;"
        aryText(46) = "clockIndicator=0;"
        aryText(47) = "deathMessages=1;"
        aryText(48) = "enemyTag=0;"
        aryText(49) = "friendlyTag=0;"
        aryText(50) = "hud=0;"
        aryText(51) = "hudGroupInfo=0;"
        aryText(52) = "hudPerm=0;"
        aryText(53) = "hudWp=0;"
        aryText(54) = "hudWpPerm=0"
        aryText(55) = "map=0;"
        aryText(56) = "netStats=1;"
        aryText(57) = "tracers=0;"
        aryText(58) = "ultraAI=1;"
        aryText(59) = "unlimitedSaves=0;"
        aryText(60) = "vonID=0;"
        aryText(61) = "weaponCursor=0;"
        aryText(62) = "ExtendetInfoType=0;"
        aryText(63) = "MineTag=0;"
        aryText(64) = "};"
        aryText(65) = "skillFriendly=0.6;"
        aryText(66) = "precisionFriendly=0.6;"
        aryText(67) = "skillEnemy=0.28;"
        aryText(68) = "precisionEnemy=0.28;"
        aryText(69) = "};"
        aryText(70) = "class Veteran"
        aryText(71) = "{"
        aryText(72) = "class Flags"
        aryText(73) = "{"
        aryText(74) = "3rdPersonView=1;"
        aryText(75) = "armor=0;"
        aryText(76) = "autoAim=0;"
        aryText(77) = "autoGuideAT=0;"
        aryText(78) = "autoSpot=0;"
        aryText(79) = "cameraShake=1;"
        aryText(80) = "clockIndicator=0;"
        aryText(81) = "deathMessages=1;"
        aryText(82) = "enemyTag=0;"
        aryText(83) = "friendlyTag=0;"
        aryText(84) = "hud=0;"
        aryText(85) = "hudGroupInfo=0;"
        aryText(86) = "hudPerm=0;"
        aryText(87) = "hudWp=0;"
        aryText(88) = "hudWpPerm=0;"
        aryText(89) = "map=0;"
        aryText(90) = "netStats=1;"
        aryText(91) = "tracers=0;"
        aryText(92) = "ultraAI=1;"
        aryText(93) = "unlimitedSaves=0;"
        aryText(94) = "vonID=0;"
        aryText(95) = "weaponCursor=0;"
        aryText(96) = "ExtendetInfoType=0;"
        aryText(97) = "MineTag=0;"
        aryText(98) = "};"
        aryText(99) = "skillFriendly=1;"
        aryText(100) = "precisionFriendly=1;"
        aryText(101) = "skillEnemy=1;"
        aryText(102) = "precisionEnemy=1;"
        aryText(103) = "};"
        aryText(104) = "class Mercenary"
        aryText(105) = "{"
        aryText(106) = "class Flags"
        aryText(107) = "{"
        aryText(108) = "3rdPersonView=0;"
        aryText(109) = "armor=0;"
        aryText(110) = "autoAim=0;"
        aryText(111) = "autoGuideAT=0;"
        aryText(112) = "autoSpot=0;"
        aryText(113) = "cameraShake=1;"
        aryText(114) = "clockIndicator=0;"
        aryText(115) = "deathMessages=0;"
        aryText(116) = "enemyTag=0;"
        aryText(117) = "friendlyTag=0;"
        aryText(118) = "hud=0;"
        aryText(119) = "hudGroupInfo=0;"
        aryText(120) = "hudPerm=0;"
        aryText(121) = "hudWp=0;"
        aryText(122) = "hudWpPerm=0;"
        aryText(123) = "map=0;"
        aryText(124) = "netStats=0;"
        aryText(125) = "tracers=0;"
        aryText(126) = "ultraAI=0;"
        aryText(127) = "unlimitedSaves=0;"
        aryText(128) = "vonID=0;"
        aryText(129) = "weaponCursor=0;"
        aryText(130) = "ExtendetInfoType=0;"
        aryText(131) = "MineTag=0;"
        aryText(132) = "};"
        aryText(133) = "skillFriendly=1;"
        aryText(134) = "precisionFriendly=1;"
        aryText(135) = "skillEnemy=1;"
        aryText(136) = "precisionEnemy=1;"
        aryText(137) = "};"
        aryText(138) = "};"
        aryText(139) = "difficulty=""recruit"";"
        Using sw As New StreamWriter(variable)
            For x = 0 To 139
                sw.WriteLine(aryText(x))
            Next
            sw.Close()
        End Using
    End Sub
    Sub leermods()
        perfilcambiante = esusservera3 & "\" & ComboBox1.SelectedItem.ToString
        mods = Combine(perfilcambiante, addon)
        If My.Computer.FileSystem.FileExists(mods) Then
            Try
                Using rdr As New System.IO.StreamReader(mods)
                    Do While rdr.Peek() >= 0
                        Dim itm As String = rdr.ReadLine
                        itm = itm.Trim

                        If itm <> "" Then
                            For i As Integer = 0 To CheckedListBox1.Items.Count - 1
                                If CheckedListBox1.Items(i).ToString = itm Then
                                    CheckedListBox1.SetItemCheckState(i, CheckState.Checked)
                                    Exit For
                                End If
                            Next
                        End If
                    Loop
                End Using
            Catch ex As Exception

            End Try

        End If



        If IO.File.Exists(prioridadmods) Then
            Try
                Dim r As New IO.StreamReader(prioridadmods)
                Dim txt As New TextBox
                txt.Text = r.ReadToEnd
                ListBox1.Items.Clear()
                ListBox2.Items.Clear()

                For i As Integer = 0 To txt.Lines.Count - 2
                    ListBox1.Items.Add(txt.Lines(i))
                    ListBox2.Items.Add(txt.Lines(i))
                Next
                r.Close()
            Catch ex As Exception

            End Try
            Call construirparametro()
        End If
    End Sub
    Sub construirparametro()
        perfilcambiante = esusservera3 & "\" & ComboBox1.SelectedItem.ToString
        carpetausercambiante = perfilcambiante & "\" & "Users"
        carpetausuariocambiante = carpetausercambiante & "\" & usuario
        puerto = Combine(perfilcambiante, txtpuerto)
        esusbasico = Combine(perfilcambiante, "Esus_basico.cfg")
        esusconfig = Combine(perfilcambiante, "Esus_config.cfg")
        dificultad = Combine(carpetausuariocambiante, usuario & ".Arma3Profile")
        variable = dificultad
        Dim builder As New StringBuilder()
        For Each i As Object In ListBox1.Items
            i = i + ";"
            builder.Append(i.ToString())
        Next
        Dim parametros As String = Nothing
        If CheckBox1.Checked = True Then
            parametros = "-loadMissionToMemory"
        Else
            parametros = Nothing

        End If

        If TextBox5.Text = Nothing Then
        Else
            parametros = parametros & " " & "-maxMem=" & TextBox5.Text
        End If
        If TextBox16.Text = Nothing Then
        Else
            parametros = parametros & " " & "-cpuCount=" & TextBox16.Text
        End If
        If TextBox17.Text = Nothing Then
        Else
            parametros = parametros & " " & "-exThreads=" & TextBox17.Text
        End If
        If TextBox2.Text = Nothing Then
        Else
            parametros = parametros & " " & TextBox2.Text
        End If
        TextBox1.Text = "-port=" & TextBox45.Text & " " & "-mod=" & builder.ToString() & " ""-config=" & esusconfig & """" & " " & " ""-cfg=" & esusbasico & """" & " " & " ""-profiles=" & perfilcambiante & """" & " " & " -name= " & ComboBox1.SelectedItem.ToString & " " & parametros
    End Sub
    Sub informacion()
        Dim nombrecpu As String
        nombrecpu = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString", Nothing)
        Label59.Text = nombrecpu
        Label35.Text = System.Environment.MachineName
        Label34.Text = System.Environment.UserName
        Label33.Text = My.Computer.Info.OSFullName
        Label32.Text = My.Computer.Info.OSPlatform
        Label29.Text = My.Computer.Info.OSVersion
        Label31.Text = My.Computer.Info.InstalledUICulture.ToString
        Timer1.Enabled = True
        Timer2.Enabled = True
    End Sub

    Sub leerperfilbasico()
        Try
            Dim cero As String = System.IO.File.ReadAllLines(esusbasico)(0)
            Dim uno As String = System.IO.File.ReadAllLines(esusbasico)(1)
            Dim dos As String = System.IO.File.ReadAllLines(esusbasico)(2)
            Dim tres As String = System.IO.File.ReadAllLines(esusbasico)(3)
            Dim cuatro As String = System.IO.File.ReadAllLines(esusbasico)(4)
            Dim cinco As String = System.IO.File.ReadAllLines(esusbasico)(5)
            Dim seis As String = System.IO.File.ReadAllLines(esusbasico)(6)
            Dim siete As String = System.IO.File.ReadAllLines(esusbasico)(7)
            Dim ocho As String = System.IO.File.ReadAllLines(esusbasico)(8)
            Dim nueve As String = System.IO.File.ReadAllLines(esusbasico)(9)
            Dim catorce As String = System.IO.File.ReadAllLines(esusbasico)(14)
            Dim quince As String = System.IO.File.ReadAllLines(esusbasico)(15)
            Dim kbyte As Integer
            Dim megabyte As Integer
            Dim cara As Integer
            Dim aryText(16) As String
            uno = Replace(uno, "MinBandwidth =", "")
            uno = Replace(uno, ";", "")
            dos = Replace(dos, "MaxBandwidth =", "")
            dos = Replace(dos, ";", "")
            tres = Replace(tres, "MaxMsgSend =", "")
            tres = Replace(tres, ";", "")
            cuatro = Replace(cuatro, "MaxSizeGuaranteed = ", "")
            cuatro = Replace(cuatro, ";", "")
            cinco = Replace(cinco, "MaxSizeNonguaranteed =", "")
            cinco = Replace(cinco, ";", "")
            seis = Replace(seis, "MinErrorToSend = ", "")
            seis = Replace(seis, ";", "")
            siete = Replace(siete, "MinErrorToSendNear =", "")
            siete = Replace(siete, ";", "")
            ocho = Replace(ocho, "MaxCustomFileSize = ", "")
            ocho = Replace(ocho, ";", "")
            nueve = Replace(nueve, "class sockets{maxPacketSize =", "")
            nueve = Replace(nueve, ";};", "")
            catorce = Replace(catorce, "terrainGrid=", "")
            catorce = Replace(catorce, ";", "")
            quince = Replace(quince, "viewDistance=", "")
            quince = Replace(quince, ";", "")
            kbyte = uno
            kbyte = kbyte / 1024
            TextBox7.Text = kbyte
            megabyte = dos
            megabyte = megabyte / 1024 / 1024
            TextBox8.Text = megabyte
            TextBox9.Text = tres
            TextBox10.Text = cuatro
            TextBox11.Text = cinco
            TextBox12.Text = seis
            TextBox13.Text = siete
            cara = ocho
            cara = cara / 1024
            TextBox14.Text = cara
            TextBox15.Text = nueve
            NumericUpDown1.Text = catorce
            NumericUpDown2.Text = quince
            TextBox9.Text = TextBox9.Text.Replace(" ", "")
            TextBox11.Text = TextBox11.Text.Replace(" ", "")
            TextBox13.Text = TextBox13.Text.Replace(" ", "")
            TextBox15.Text = TextBox15.Text.Replace(" ", "")
        Catch ex As Exception

        End Try

    End Sub
    Sub leerperfilconfig()
        Try
            Dim cero As String = System.IO.File.ReadAllLines(esusconfig)(0)
            Dim uno As String = System.IO.File.ReadAllLines(esusconfig)(1)
            Dim dos As String = System.IO.File.ReadAllLines(esusconfig)(2)
            Dim tres As String = System.IO.File.ReadAllLines(esusconfig)(3)
            Dim cuatro As String = System.IO.File.ReadAllLines(esusconfig)(4)
            Dim cinco As String = System.IO.File.ReadAllLines(esusconfig)(5)
            Dim seis As String = System.IO.File.ReadAllLines(esusconfig)(6)
            Dim siete As String = System.IO.File.ReadAllLines(esusconfig)(7)
            Dim ocho As String = System.IO.File.ReadAllLines(esusconfig)(8)
            Dim nueve As String = System.IO.File.ReadAllLines(esusconfig)(9)
            Dim diez As String = System.IO.File.ReadAllLines(esusconfig)(10)
            Dim once As String = System.IO.File.ReadAllLines(esusconfig)(11)
            Dim doce As String = System.IO.File.ReadAllLines(esusconfig)(12)
            Dim trece As String = System.IO.File.ReadAllLines(esusconfig)(13)
            Dim catorce As String = System.IO.File.ReadAllLines(esusconfig)(14)
            Dim quince As String = System.IO.File.ReadAllLines(esusconfig)(15)
            Dim dieciseis As String = System.IO.File.ReadAllLines(esusconfig)(16)
            Dim diecisiete As String = System.IO.File.ReadAllLines(esusconfig)(17)
            Dim dieciocho As String = System.IO.File.ReadAllLines(esusconfig)(18)
            Dim diecinueve As String = System.IO.File.ReadAllLines(esusconfig)(19)
            Dim veinte As String = System.IO.File.ReadAllLines(esusconfig)(20)
            Dim veintiuno As String = System.IO.File.ReadAllLines(esusconfig)(21)
            Dim veintidos As String = System.IO.File.ReadAllLines(esusconfig)(22)
            Dim veintitres As String = System.IO.File.ReadAllLines(esusconfig)(23)
            Dim veinticuatro As String = System.IO.File.ReadAllLines(esusconfig)(24)
            Dim veinticinco As String = System.IO.File.ReadAllLines(esusconfig)(25)
            Dim veintiseis As String = System.IO.File.ReadAllLines(esusconfig)(26)
            Dim veintisiete As String = System.IO.File.ReadAllLines(esusconfig)(27)
            Dim veintiocho As String = System.IO.File.ReadAllLines(esusconfig)(28)
            Dim veintinueve As String = System.IO.File.ReadAllLines(esusconfig)(29)
            Dim treinta As String = System.IO.File.ReadAllLines(esusconfig)(30)
            Dim treintayuno As String = System.IO.File.ReadAllLines(esusconfig)(31)
            Dim treintaydos As String = System.IO.File.ReadAllLines(esusconfig)(32)
            Dim treintaytres As String = System.IO.File.ReadAllLines(esusconfig)(33)
            Dim treintaycuatro As String = System.IO.File.ReadAllLines(esusconfig)(34)
            Dim treintaycinco As String = System.IO.File.ReadAllLines(esusconfig)(35)
            Dim treintayseis As String = System.IO.File.ReadAllLines(esusconfig)(36)
            Dim treintaysiete As String = System.IO.File.ReadAllLines(esusconfig)(37)
            Dim treintayocho As String = System.IO.File.ReadAllLines(esusconfig)(38)
            Dim treintaynueve As String = System.IO.File.ReadAllLines(esusconfig)(39)
            Dim cuarenta As String = System.IO.File.ReadAllLines(esusconfig)(40)
            Dim cuarentayuno As String = System.IO.File.ReadAllLines(esusconfig)(41)
            Dim cuarentaydos As String = System.IO.File.ReadAllLines(esusconfig)(42)
            Dim cuarentaytres As String = System.IO.File.ReadAllLines(esusconfig)(43)
            Dim cuarentaycuatro As String = System.IO.File.ReadAllLines(esusconfig)(44)
            Dim cuarentaycinco As String = System.IO.File.ReadAllLines(esusconfig)(45)
            Dim cuarentayseis As String = System.IO.File.ReadAllLines(esusconfig)(46)
            Dim cuarentaysiete As String = System.IO.File.ReadAllLines(esusconfig)(47)
            Dim cuarentayocho As String = System.IO.File.ReadAllLines(esusconfig)(48)
            cero = Replace(cero, "steamPort =", "")
            cero = Replace(cero, ";", "")
            uno = Replace(uno, Chr(34), "")
            uno = Replace(uno, ";", "")
            uno = Replace(uno, "=", "")
            dos = Replace(dos, Chr(34), "")
            dos = Replace(dos, ";", "")
            dos = Replace(dos, "=", "")
            tres = Replace(tres, Chr(34), "")
            tres = Replace(tres, ";", "")
            tres = Replace(tres, "=", "")
            If cuatro = Nothing Then
                CheckBox8.Checked = False
            Else
                CheckBox8.Checked = True
            End If
            cinco = Replace(cinco, Chr(34), "")
            cinco = Replace(cinco, "motd[] = {", "")
            cinco = Replace(cinco, ",", "")
            seis = Replace(seis, Chr(34), "")
            seis = Replace(seis, ",", "")
            siete = Replace(siete, Chr(34), "")
            siete = Replace(siete, ",", "")
            ocho = Replace(ocho, Chr(34), "")
            ocho = Replace(ocho, ",", "")
            nueve = Replace(nueve, Chr(34), "")
            nueve = Replace(nueve, ",", "")
            diez = Replace(diez, Chr(34), "")
            diez = Replace(diez, ",", "")
            once = Replace(once, Chr(34), "")
            once = Replace(once, ",", "")
            doce = Replace(doce, Chr(34), "")
            doce = Replace(doce, ",", "")
            trece = Replace(trece, Chr(34), "")
            trece = Replace(trece, ",", "")
            catorce = Replace(catorce, Chr(34), "")
            catorce = Replace(catorce, ",", "")
            TextBox42.Text = cinco & vbNewLine & seis & vbNewLine & siete & vbNewLine & ocho & vbNewLine & nueve & vbNewLine & diez & vbNewLine & once & vbNewLine & doce & vbNewLine & trece & vbNewLine & catorce & vbNewLine & quince

            diecisiete = Replace(diecisiete, "motdInterval =", "")
            diecisiete = Replace(diecisiete, ";", "")

            NumericUpDown4.Text = diecisiete
            diecinueve = Replace(diecinueve, "maxPlayers =", "")
            diecinueve = Replace(diecinueve, ";", "")

            If veintitres = "kickduplicate = 0;" Then
                CheckBox5.Checked = False
            Else
                CheckBox5.Checked = True
            End If
            TextBox43.Text = cero
            TextBox48.Text = Trim(Mid(uno, InStr(uno, " ")))
            TextBox46.Text = Trim(Mid(dos, InStr(dos, " ")))
            TextBox47.Text = Trim(Mid(tres, InStr(tres, " ")))
            NumericUpDown3.Text = diecinueve
            veinticuatro = Replace(veinticuatro, "voteMissionPlayers =", "")
            veinticuatro = Replace(veinticuatro, ";", "")
            NumericUpDown5.Text = veinticuatro
            If veintiuno = "verifySignatures = 0;" Then
                ComboBox4.SelectedIndex = 0
            Else
                ComboBox3.SelectedIndex = 1
            End If
            If veintidos = "requiredSecureId = 0;" Then
                ComboBox5.SelectedIndex = 0
            Else
                ComboBox5.SelectedIndex = 1
            End If
            If veinticinco = "disableVoN = 0;" Then
                CheckBox2.Checked = True
            Else
                CheckBox2.Checked = False
            End If
            If veintiseis = "Headlessclients[]={};" Then
            ElseIf veintiseis = "Headlessclients[]={  };" Then
                CheckBox15.Checked = False
            Else
                CheckBox15.Checked = True
                veintiseis = Replace(veintiseis, "Headlessclients[]={", "")
                veintiseis = Replace(veintiseis, "};", "")
                TextBox62.Text = veintiseis
            End If
            veintisiete = Replace(veintisiete, "voteThreshold =", "")
            veintisiete = Replace(veintisiete, ";", "")
            veintisiete = Replace(veintisiete, "0.", "")
            NumericUpDown6.Text = veintisiete

            veintiocho = Replace(veintiocho, "vonCodecQuality =", "")
            veintiocho = Replace(veintiocho, ";", "")
            NumericUpDown7.Text = veintiocho

            If veintinueve = "persistent = 0;" Then
                CheckBox4.Checked = False
            Else
                CheckBox4.Checked = True
            End If

            If treinta = "timeStampFormat = ""none"";" Then
                ComboBox6.SelectedIndex = 0
            Else
                If treinta = "timeStampFormat = ""short"";" Then
                    ComboBox6.SelectedIndex = 1
                Else
                    ComboBox6.SelectedIndex = 2
                End If

            End If
            If treintayuno = "BattlEye = 0;" Then
                CheckBox6.Checked = False
            Else

                CheckBox6.Checked = True
            End If

            treintaydos = Replace(treintaydos, "doubleIdDetected =", "")
            treintaydos = Replace(treintaydos, ";", "")
            treintaytres = Replace(treintaytres, "onUserConnected =", "")
            treintaytres = Replace(treintaytres, ";", "")
            treintaycuatro = Replace(treintaycuatro, "onUserDisconnected =", "")
            treintaycuatro = Replace(treintaycuatro, ";", "")
            treintaycinco = Replace(treintaycinco, "onHackedData =", "")
            treintaycinco = Replace(treintaycinco, ";", "")
            treintayseis = Replace(treintayseis, "onDifferentData =", "")
            treintayseis = Replace(treintayseis, ";", "")
            treintaysiete = Replace(treintaysiete, "onUnsignedData =", "")
            treintaysiete = Replace(treintaysiete, ";", "")
            treintayocho = Replace(treintayocho, "regularCheck =", "")
            treintayocho = Replace(treintayocho, ";", "")
            TextBox39.Text = treintaydos
            TextBox38.Text = treintaytres
            TextBox37.Text = treintaycuatro
            TextBox36.Text = treintaycinco
            TextBox35.Text = treintayseis
            TextBox34.Text = treintaysiete
            TextBox33.Text = treintayocho
            If treintaynueve = "forceRotorLibSimulation = 0;" Then
                ComboBox3.SelectedIndex = 0
            Else
                ComboBox3.SelectedIndex = 1
            End If
            cuarenta = Replace(cuarenta, "requiredBuild =", "")
            cuarenta = Replace(cuarenta, ";", "")
            TextBox21.Text = cuarenta
            cuarentaycinco = Replace(cuarentaycinco, Chr(34), "")
            cuarentaycinco = Replace(cuarentaycinco, ";", "")
            cuarentaycinco = Replace(cuarentaycinco, "=", "")
            misionchecked = Trim(Mid(cuarentaycinco, InStr(cuarentaycinco, " ")))
            misionchecked = misionchecked & ".pbo"
            If misionchecked.Contains("&vacio&") Then
                CheckedListBox2.Items.Clear()
                For Each File In System.IO.Directory.GetFiles(mpmision, "*.pbo")
                    CheckedListBox2.Items.Add(Path.GetFileName(File))
                Next
            Else
                Dim I As Integer
                For I = 0 To CheckedListBox2.Items.Count - 1
                    If CheckedListBox2.Items(I).IndexOf(misionchecked) <> -1 Then
                        CheckedListBox2.SetItemChecked(I, True)
                    Else

                    End If
                Next
                TextBox66.Text = CheckedListBox2.CheckedItems.Count
            End If
            If cuarentayseis = "difficulty = ""recruit"";" Then
                ComboBox7.SelectedIndex = 0
            ElseIf cuarentayseis = "difficulty = ""regular"";" Then
                ComboBox7.SelectedIndex = 1
            End If
            If cuarentayseis = "difficulty = ""veteran"";" Then
                ComboBox7.SelectedIndex = 2
            ElseIf cuarentayseis = "difficulty = ""mercenary"";" Then
                ComboBox7.SelectedIndex = 3
            End If
        Catch ex As Exception
        End Try
    End Sub
    Private Sub borrarmapasduplicados()
        For Row As Int16 = 0 To ComboBox2.Items.Count - 2
            For RowAgain As Int16 = ComboBox2.Items.Count - 1 To Row + 1 Step -1
                If ComboBox2.Items(Row).ToString = ComboBox2.Items(RowAgain).ToString Then
                    ComboBox2.Items.RemoveAt(RowAgain)
                End If
            Next
        Next
    End Sub


    Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
        Dim checked As Boolean = False
        For i As Integer = 0 To CheckedListBox1.Items.Count - 1
            CheckedListBox1.SetItemChecked(i, checked)
        Next
        ListBox1.Items.Clear()
        ListBox2.Items.Clear()
        If ListBox1.Items.Count > 0 Then
            For i As Integer = 0 To ListBox1.Items.Count - 1
                ListBox2.Items.Add(ListBox1.Items(i))
            Next
        Else
            ListBox2.Items.Clear()
        End If
        ListBox3.Items.Clear()
        TextBox67.Text = CheckedListBox1.CheckedItems.Count
        Call construirparametro()

    End Sub

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        For i As Integer = 0 To CheckedListBox1.Items.Count - 1
            If CheckedListBox1.GetItemChecked(i) = True Then
                CheckedListBox1.SetItemChecked(i, False)
            ElseIf CheckedListBox1.GetItemChecked(i) = False Then
                CheckedListBox1.SetItemChecked(i, True)
            End If
        Next
        ListBox1.Items.Clear()
        If CheckedListBox1.CheckedItems.Count > 0 Then
            For i As Integer = 0 To CheckedListBox1.CheckedItems.Count - 1
                ListBox1.Items.Add(CheckedListBox1.CheckedItems(i))
            Next
        End If
        ListBox2.Items.Clear()
        If ListBox1.Items.Count > 0 Then
            For i As Integer = 0 To ListBox1.Items.Count - 1
                ListBox2.Items.Add(ListBox1.Items(i))
            Next
        Else
            ListBox2.Items.Clear()
        End If
        ListBox3.Items.Clear()
        TextBox67.Text = CheckedListBox1.CheckedItems.Count
        Call construirparametro()


    End Sub

    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        Dim checked As Boolean = True
        For i As Integer = 0 To CheckedListBox1.Items.Count - 1
            CheckedListBox1.SetItemChecked(i, checked)
        Next
        ListBox1.Items.Clear()
        If CheckedListBox1.CheckedItems.Count > 0 Then
            For i As Integer = 0 To CheckedListBox1.CheckedItems.Count - 1
                ListBox1.Items.Add(CheckedListBox1.CheckedItems(i))
            Next
        End If
        ListBox2.Items.Clear()
        If ListBox1.Items.Count > 0 Then
            For i As Integer = 0 To ListBox1.Items.Count - 1
                ListBox2.Items.Add(ListBox1.Items(i))
            Next
        Else
            ListBox2.Items.Clear()
        End If
        ListBox3.Items.Clear()
        TextBox67.Text = CheckedListBox1.CheckedItems.Count
        Call construirparametro()


    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        CheckedListBox1.Items.Clear()
        For Each folder In System.IO.Directory.GetDirectories(rutaarma, "@*")
            CheckedListBox1.Items.Add(Path.GetFileName(folder))
        Next
        ListBox2.Items.Clear()
        If ListBox1.Items.Count > 0 Then
            For i As Integer = 0 To ListBox1.Items.Count - 1
                ListBox2.Items.Add(ListBox1.Items(i))
            Next
        Else
            ListBox2.Items.Clear()
        End If
        ListBox3.Items.Clear()
        ListBox2.Items.Clear()
        ListBox1.Items.Clear()
        TextBox67.Text = CheckedListBox1.CheckedItems.Count
        TextBox68.Text = CheckedListBox1.Items.Count
        Call construirparametro()

    End Sub


    Private Sub CheckedListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CheckedListBox1.SelectedIndexChanged
        ListBox1.Items.Clear()
        If CheckedListBox1.CheckedItems.Count > 0 Then
            For i As Integer = 0 To CheckedListBox1.CheckedItems.Count - 1
                ListBox1.Items.Add(CheckedListBox1.CheckedItems(i))
            Next
        Else
            ListBox1.Items.Clear()
        End If
        ListBox2.Items.Clear()
        If ListBox1.Items.Count > 0 Then
            For i As Integer = 0 To ListBox1.Items.Count - 1
                ListBox2.Items.Add(ListBox1.Items(i))
            Next
        Else
            ListBox2.Items.Clear()
        End If
        ListBox3.Items.Clear()
        TextBox67.Text = CheckedListBox1.CheckedItems.Count
        Call construirparametro()
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
        CheckedListBox3.Visible = True
        CheckedListBox3.Items.Clear()
        For Each s As String In CheckedListBox2.Items
            If s.Contains(ComboBox2.SelectedItem.ToString) Then
                CheckedListBox3.Items.Add(s)
            End If
        Next
        Dim itemChecked As Object = Nothing
        Dim elegido As String = Nothing
        For Each itemChecked In CheckedListBox2.CheckedItems
            elegido = itemChecked
        Next
        For a = 0 To CheckedListBox3.Items.Count - 1
            Try
                If CheckedListBox3.Items(a).indexof(elegido) <> -1 Then
                    CheckedListBox3.SetItemChecked(a, True)
                End If
            Catch ex As Exception

            End Try

        Next
        CheckedListBox2.Visible = False

    End Sub


    Private Sub CheckedListBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CheckedListBox3.SelectedIndexChanged
        CheckedListBox3.Visible = True
        CheckedListBox2.Visible = False

        Dim itemChecked As Object = Nothing
        Dim elegido As String = Nothing
        For Each itemChecked In CheckedListBox3.CheckedItems
            elegido = itemChecked
        Next
        Dim checked As Boolean = False
        For i As Integer = 0 To CheckedListBox2.Items.Count - 1
            CheckedListBox2.SetItemChecked(i, checked)
        Next
        TextBox66.Text = CheckedListBox3.CheckedItems.Count
    End Sub

    Private Sub CheckedListBox2_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox2.ItemCheck
        If e.NewValue = CheckState.Checked Then
            For i As Integer = 0 To Me.CheckedListBox2.Items.Count - 1 Step 1
                If i <> e.Index Then
                    Me.CheckedListBox2.SetItemChecked(i, False)
                End If
            Next i
        End If
    End Sub
    Private Sub CheckedListBox3_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox3.ItemCheck
        If e.NewValue = CheckState.Checked Then
            For i As Integer = 0 To Me.CheckedListBox3.Items.Count - 1 Step 1
                If i <> e.Index Then
                    Me.CheckedListBox3.SetItemChecked(i, False)
                End If
            Next i
        End If
    End Sub

    Private Sub CheckedListBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CheckedListBox2.SelectedIndexChanged

        TextBox66.Text = CheckedListBox2.CheckedItems.Count
    End Sub

    Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        CheckedListBox2.Visible = True
        Dim itemChecked As Object = Nothing
        Dim elegido As String = Nothing
        For Each itemChecked In CheckedListBox3.CheckedItems
            elegido = itemChecked
        Next
        For a = 0 To CheckedListBox2.Items.Count - 1
            Try
                If CheckedListBox2.Items(a).indexof(elegido) <> -1 Then
                    CheckedListBox2.SetItemChecked(a, True)
                End If
            Catch ex As Exception

            End Try

        Next
        CheckedListBox3.Visible = False
    End Sub

    Private Sub arriba_Click(sender As Object, e As EventArgs) Handles arriba.Click
        If ListBox1.SelectedItem = Nothing Then
        Else
            If ListBox1.SelectedIndex > 0 Then
                Dim I = ListBox1.SelectedIndex - 1
                ListBox1.Items.Insert(I, ListBox1.SelectedItem)
                ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
                ListBox1.SelectedIndex = I
            End If
        End If
        ListBox2.Items.Clear()
        If ListBox1.Items.Count > 0 Then
            For i As Integer = 0 To ListBox1.Items.Count - 1
                ListBox2.Items.Add(ListBox1.Items(i))
            Next
        Else
            ListBox2.Items.Clear()
        End If
        ListBox3.Items.Clear()
        Call construirparametro()
    End Sub

    Private Sub abajo_Click(sender As Object, e As EventArgs) Handles abajo.Click
        If ListBox1.SelectedItem = Nothing Then
        Else
            If ListBox1.SelectedIndex < ListBox1.Items.Count - 1 Then
                Dim I = ListBox1.SelectedIndex + 2
                ListBox1.Items.Insert(I, ListBox1.SelectedItem)
                ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
                ListBox1.SelectedIndex = I - 1
            End If
        End If
        ListBox2.Items.Clear()
        If ListBox1.Items.Count > 0 Then
            For i As Integer = 0 To ListBox1.Items.Count - 1
                ListBox2.Items.Add(ListBox1.Items(i))
            Next
        Else
            ListBox2.Items.Clear()
        End If
        ListBox3.Items.Clear()
        Call construirparametro()
    End Sub

    Private Sub moverarriba_Click(sender As Object, e As EventArgs) Handles moverarriba.Click
        Dim item As String
        If ListBox1.SelectedItem = Nothing Then
            item = Nothing
        Else
            item = ListBox1.SelectedItem
            ListBox1.Items.Remove(item)
            ListBox1.Items.Insert(0, item)
            ListBox1.SelectedIndex = 0
        End If
        ListBox2.Items.Clear()
        If ListBox1.Items.Count > 0 Then
            For i As Integer = 0 To ListBox1.Items.Count - 1
                ListBox2.Items.Add(ListBox1.Items(i))
            Next
        Else
            ListBox2.Items.Clear()
        End If
        ListBox3.Items.Clear()
        Call construirparametro()
    End Sub

    Private Sub moverabajo_Click(sender As Object, e As EventArgs) Handles moverabajo.Click
        Dim limite As Integer = (ListBox1.Items.Count - 1)
        Dim item As String
        If ListBox1.SelectedItem = Nothing Then
            item = Nothing
        Else
            item = ListBox1.SelectedItem
            ListBox1.Items.Remove(item)
            ListBox1.Items.Insert(limite, item)
            ListBox1.SelectedIndex = limite
        End If
        ListBox2.Items.Clear()
        If ListBox1.Items.Count > 0 Then
            For i As Integer = 0 To ListBox1.Items.Count - 1
                ListBox2.Items.Add(ListBox1.Items(i))
            Next
        Else
            ListBox2.Items.Clear()
        End If
        ListBox3.Items.Clear()
        Call construirparametro()
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged

    End Sub

    Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
        Dim item As String
        If ListBox2.SelectedItem = Nothing Then
            item = Nothing
        Else
            item = ListBox2.SelectedItem
            ListBox2.Items.Remove(item)
            ListBox2.Items.Insert(0, item)
            ListBox2.SelectedIndex = 0
        End If
    End Sub

    Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
        If ListBox2.SelectedItem = Nothing Then
        Else
            If ListBox2.SelectedIndex > 0 Then
                Dim I = ListBox2.SelectedIndex - 1
                ListBox2.Items.Insert(I, ListBox2.SelectedItem)
                ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
                ListBox2.SelectedIndex = I
            End If
        End If
    End Sub

    Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
        If ListBox2.SelectedItem = Nothing Then
        Else
            If ListBox2.SelectedIndex < ListBox2.Items.Count - 1 Then
                Dim I = ListBox2.SelectedIndex + 2
                ListBox2.Items.Insert(I, ListBox2.SelectedItem)
                ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
                ListBox2.SelectedIndex = I - 1
            End If
        End If
    End Sub

    Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        Dim limite As Integer = (ListBox2.Items.Count - 1)
        Dim item As String
        If ListBox2.SelectedItem = Nothing Then
            item = Nothing
        Else
            item = ListBox2.SelectedItem
            ListBox2.Items.Remove(item)
            ListBox2.Items.Insert(limite, item)
            ListBox2.SelectedIndex = limite
        End If
    End Sub

    Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
        If ListBox2.SelectedItem = Nothing Then
        Else
            ListBox2.SelectedItem = ListBox3.Items.Add(ListBox2.SelectedItem)
            ListBox2.Items.Remove(ListBox2.SelectedItem)
        End If
    End Sub

    Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
        If ListBox3.SelectedItem = Nothing Then
        Else
            ListBox3.SelectedItem = ListBox2.Items.Add(ListBox3.SelectedItem)
            ListBox3.Items.Remove(ListBox3.SelectedItem)
        End If
    End Sub


    Private Sub Button1_Click(sender As Object, e As EventArgs)



    End Sub

    Private Sub Label9_Click(sender As Object, e As EventArgs) Handles Label9.Click
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        perfilcambiante = esusservera3 & "\" & ComboBox1.SelectedItem.ToString
        mods = Combine(perfilcambiante, addon)
        If System.IO.File.Exists(esusbasico) = True Then
            Dim kbyte As Integer
            Dim megabyte As Integer
            Dim aryText(16) As String
            Dim cara As Integer

            If TextBox7.Text = Nothing Then
            Else
                kbyte = TextBox7.Text
                kbyte = kbyte * 1024
            End If
            If TextBox8.Text = Nothing Then
            Else
                megabyte = TextBox8.Text
                megabyte = megabyte * 1024 * 1024
            End If
            If TextBox14.Text = Nothing Then
            Else
                cara = TextBox14.Text
                cara = cara * 1024
            End If
            aryText(0) = "adapter=-1;"
            aryText(1) = "MinBandwidth = " + kbyte.ToString & ";"
            aryText(2) = "MaxBandwidth = " + megabyte.ToString & ";"
            aryText(3) = "MaxMsgSend = " + TextBox9.Text & ";"
            aryText(4) = "MaxSizeGuaranteed = " + TextBox10.Text & ";"
            aryText(5) = "MaxSizeNonguaranteed = " + TextBox11.Text & ";"
            aryText(6) = "MinErrorToSend = " + TextBox12.Text & ";"
            aryText(7) = "MinErrorToSendNear = " + TextBox13.Text & ";"
            aryText(8) = "MaxCustomFileSize = " + cara.ToString & ";"
            aryText(9) = "class sockets{maxPacketSize = " & TextBox15.Text & ";};"
            aryText(10) = "3D_Performance=1;"
            aryText(11) = "Resolution_W=0;"
            aryText(12) = "Resolution_H=0;"
            aryText(13) = "Resolution_Bpp=32;"
            aryText(14) = "terrainGrid=" + NumericUpDown1.Text & ";"
            aryText(15) = "viewDistance=" + NumericUpDown2.Text & ";"
            aryText(16) = "Windowed=0;"
            Try
                Using sw As New StreamWriter(esusbasico)
                    For x = 0 To 16
                        sw.WriteLine(aryText(x))
                    Next
                    sw.Close()
                End Using
            Catch ex As Exception

            End Try
        Else

            MsgBox("Ha habido un problema y no ha podido realizarse el guardado")

        End If

        If System.IO.File.Exists(dificultad) = True Then
            Dim aryText(139) As String
            Dim x As Integer
            Dim index5 = ComboBox7.SelectedIndex
            Select Case index5
                Case 0
                    Try
                        aryText(0) = "class Difficulties"
                        aryText(1) = "{"
                        aryText(2) = "class Recruit"
                        aryText(3) = "{"
                        aryText(4) = "class Flags"
                        aryText(5) = "{"
                        aryText(6) = "3rdPersonView=1;"
                        aryText(7) = "armor=1;"
                        aryText(8) = "autoAim=0;"
                        aryText(9) = "autoGuideAT=1;"
                        aryText(10) = "autoSpot=1;"
                        aryText(11) = "cameraShake=0;"
                        aryText(12) = "clockIndicator=1;"
                        aryText(13) = "deathMessages=1;"
                        aryText(14) = "enemyTag=0;"
                        aryText(15) = "friendlyTag=1;"
                        aryText(16) = "hud=1;"
                        aryText(17) = "hudGroupInfo=1"
                        aryText(18) = "hudPerm=1;"
                        aryText(19) = "hudWp=1;"
                        aryText(20) = "hudWpPerm=1;"
                        aryText(21) = "map=1;"
                        aryText(22) = "netStats=1;"
                        aryText(23) = "tracers=1;"
                        aryText(24) = "ultraAI=0;"
                        aryText(25) = "unlimitedSaves=1;"
                        aryText(26) = "vonID=1;"
                        aryText(27) = "weaponCursor=1;"
                        aryText(28) = "ExtendetInfoType=1;"
                        aryText(29) = "MineTag=1;"
                        aryText(30) = "};"
                        aryText(31) = "skillFriendly=" + TextBox52.Text & ";"
                        aryText(32) = "precisionFriendly=" + TextBox51.Text & ";"
                        aryText(33) = "skillEnemy=" + TextBox50.Text & ";"
                        aryText(34) = "precisionEnemy=" + TextBox49.Text & ";"
                        aryText(35) = "};"
                        aryText(36) = "class Regular"
                        aryText(37) = "{"
                        aryText(38) = "class Flags"
                        aryText(39) = "{"
                        aryText(40) = "3rdPersonView=1;"
                        aryText(41) = "armor=0;"
                        aryText(42) = "autoAim=0;"
                        aryText(43) = "autoGuideAT=0;"
                        aryText(44) = "autoSpot=0;"
                        aryText(45) = "cameraShake=1;"
                        aryText(46) = "clockIndicator=0;"
                        aryText(47) = "deathMessages=1;"
                        aryText(48) = "enemyTag=0;"
                        aryText(49) = "friendlyTag=0;"
                        aryText(50) = "hud=0;"
                        aryText(51) = "hudGroupInfo=0;"
                        aryText(52) = "hudPerm=0;"
                        aryText(53) = "hudWp=0;"
                        aryText(54) = "hudWpPerm=0"
                        aryText(55) = "map=0;"
                        aryText(56) = "netStats=1;"
                        aryText(57) = "tracers=0;"
                        aryText(58) = "ultraAI=1;"
                        aryText(59) = "unlimitedSaves=0;"
                        aryText(60) = "vonID=0;"
                        aryText(61) = "weaponCursor=0;"
                        aryText(62) = "ExtendetInfoType=0;"
                        aryText(63) = "MineTag=0;"
                        aryText(64) = "};"
                        aryText(65) = "skillFriendly=1;"
                        aryText(66) = "precisionFriendly=1;"
                        aryText(67) = "skillEnemy=1;"
                        aryText(68) = "precisionEnemy=1;"
                        aryText(69) = "};"
                        aryText(70) = "class Veteran"
                        aryText(71) = "{"
                        aryText(72) = "class Flags"
                        aryText(73) = "{"
                        aryText(74) = "3rdPersonView=1;"
                        aryText(75) = "armor=0;"
                        aryText(76) = "autoAim=0;"
                        aryText(77) = "autoGuideAT=0;"
                        aryText(78) = "autoSpot=0;"
                        aryText(79) = "cameraShake=1;"
                        aryText(80) = "clockIndicator=0;"
                        aryText(81) = "deathMessages=1;"
                        aryText(82) = "enemyTag=0;"
                        aryText(83) = "friendlyTag=0;"
                        aryText(84) = "hud=0;"
                        aryText(85) = "hudGroupInfo=0;"
                        aryText(86) = "hudPerm=0;"
                        aryText(87) = "hudWp=0;"
                        aryText(88) = "hudWpPerm=0;"
                        aryText(89) = "map=0;"
                        aryText(90) = "netStats=1;"
                        aryText(91) = "tracers=0;"
                        aryText(92) = "ultraAI=1;"
                        aryText(93) = "unlimitedSaves=0;"
                        aryText(94) = "vonID=0;"
                        aryText(95) = "weaponCursor=0;"
                        aryText(96) = "ExtendetInfoType=0;"
                        aryText(97) = "MineTag=0;"
                        aryText(98) = "};"
                        aryText(99) = "skillFriendly=1;"
                        aryText(100) = "precisionFriendly=1;"
                        aryText(101) = "skillEnemy=1;"
                        aryText(102) = "precisionEnemy=1;"
                        aryText(103) = "};"
                        aryText(104) = "class Mercenary"
                        aryText(105) = "{"
                        aryText(106) = "class Flags"
                        aryText(107) = "{"
                        aryText(108) = "3rdPersonView=0;"
                        aryText(109) = "armor=0;"
                        aryText(110) = "autoAim=0;"
                        aryText(111) = "autoGuideAT=0;"
                        aryText(112) = "autoSpot=0;"
                        aryText(113) = "cameraShake=1;"
                        aryText(114) = "clockIndicator=0;"
                        aryText(115) = "deathMessages=0;"
                        aryText(116) = "enemyTag=0;"
                        aryText(117) = "friendlyTag=0;"
                        aryText(118) = "hud=0;"
                        aryText(119) = "hudGroupInfo=0;"
                        aryText(120) = "hudPerm=0;"
                        aryText(121) = "hudWp=0;"
                        aryText(122) = "hudWpPerm=0;"
                        aryText(123) = "map=0;"
                        aryText(124) = "netStats=0;"
                        aryText(125) = "tracers=0;"
                        aryText(126) = "ultraAI=0;"
                        aryText(127) = "unlimitedSaves=0;"
                        aryText(128) = "vonID=0;"
                        aryText(129) = "weaponCursor=0;"
                        aryText(130) = "ExtendetInfoType=0;"
                        aryText(131) = "MineTag=0;"
                        aryText(132) = "};"
                        aryText(133) = "skillFriendly=1;"
                        aryText(134) = "precisionFriendly=1;"
                        aryText(135) = "skillEnemy=1;"
                        aryText(136) = "precisionEnemy=1;"
                        aryText(137) = "};"
                        aryText(138) = "};"
                        aryText(139) = "difficulty=""recruit"";"
                        Try
                            Using sw As New StreamWriter(variable)
                                For x = 0 To 139
                                    sw.WriteLine(aryText(x))
                                Next
                                sw.Close()
                            End Using
                        Catch ex As Exception

                        End Try
                       
                    Catch ex As Exception
                    End Try

                Case 1
                    Try
                        aryText(0) = "class Difficulties"
                        aryText(1) = "{"
                        aryText(2) = "class Recruit"
                        aryText(3) = "{"
                        aryText(4) = "class Flags"
                        aryText(5) = "{"
                        aryText(6) = "3rdPersonView=1;"
                        aryText(7) = "armor=1;"
                        aryText(8) = "autoAim=0;"
                        aryText(9) = "autoGuideAT=1;"
                        aryText(10) = "autoSpot=1;"
                        aryText(11) = "cameraShake=0;"
                        aryText(12) = "clockIndicator=1;"
                        aryText(13) = "deathMessages=1;"
                        aryText(14) = "enemyTag=0;"
                        aryText(15) = "friendlyTag=1;"
                        aryText(16) = "hud=1;"
                        aryText(17) = "hudGroupInfo=1"
                        aryText(18) = "hudPerm=1;"
                        aryText(19) = "hudWp=1;"
                        aryText(20) = "hudWpPerm=1;"
                        aryText(21) = "map=1;"
                        aryText(22) = "netStats=1;"
                        aryText(23) = "tracers=1;"
                        aryText(24) = "ultraAI=0;"
                        aryText(25) = "unlimitedSaves=1;"
                        aryText(26) = "vonID=1;"
                        aryText(27) = "weaponCursor=1;"
                        aryText(28) = "ExtendetInfoType=1;"
                        aryText(29) = "MineTag=1;"
                        aryText(30) = "};"
                        aryText(31) = "skillFriendly=" + TextBox52.Text & ";"
                        aryText(32) = "precisionFriendly=" + TextBox51.Text & ";"
                        aryText(33) = "skillEnemy=" + TextBox50.Text & ";"
                        aryText(34) = "precisionEnemy=" + TextBox49.Text & ";"
                        aryText(35) = "};"
                        aryText(36) = "class Regular"
                        aryText(37) = "{"
                        aryText(38) = "class Flags"
                        aryText(39) = "{"
                        aryText(40) = "3rdPersonView=1;"
                        aryText(41) = "armor=0;"
                        aryText(42) = "autoAim=0;"
                        aryText(43) = "autoGuideAT=0;"
                        aryText(44) = "autoSpot=0;"
                        aryText(45) = "cameraShake=1;"
                        aryText(46) = "clockIndicator=0;"
                        aryText(47) = "deathMessages=1;"
                        aryText(48) = "enemyTag=0;"
                        aryText(49) = "friendlyTag=0;"
                        aryText(50) = "hud=0;"
                        aryText(51) = "hudGroupInfo=0;"
                        aryText(52) = "hudPerm=0;"
                        aryText(53) = "hudWp=0;"
                        aryText(54) = "hudWpPerm=0"
                        aryText(55) = "map=0;"
                        aryText(56) = "netStats=1;"
                        aryText(57) = "tracers=0;"
                        aryText(58) = "ultraAI=1;"
                        aryText(59) = "unlimitedSaves=0;"
                        aryText(60) = "vonID=0;"
                        aryText(61) = "weaponCursor=0;"
                        aryText(62) = "ExtendetInfoType=0;"
                        aryText(63) = "MineTag=0;"
                        aryText(64) = "};"
                        aryText(65) = "skillFriendly=" + TextBox52.Text & ";"
                        aryText(66) = "precisionFriendly=" + TextBox51.Text & ";"
                        aryText(67) = "skillEnemy=" + TextBox50.Text & ";"
                        aryText(68) = "precisionEnemy=" + TextBox49.Text & ";"
                        aryText(69) = "};"
                        aryText(70) = "class Veteran"
                        aryText(71) = "{"
                        aryText(72) = "class Flags"
                        aryText(73) = "{"
                        aryText(74) = "3rdPersonView=1;"
                        aryText(75) = "armor=0;"
                        aryText(76) = "autoAim=0;"
                        aryText(77) = "autoGuideAT=0;"
                        aryText(78) = "autoSpot=0;"
                        aryText(79) = "cameraShake=1;"
                        aryText(80) = "clockIndicator=0;"
                        aryText(81) = "deathMessages=1;"
                        aryText(82) = "enemyTag=0;"
                        aryText(83) = "friendlyTag=0;"
                        aryText(84) = "hud=0;"
                        aryText(85) = "hudGroupInfo=0;"
                        aryText(86) = "hudPerm=0;"
                        aryText(87) = "hudWp=0;"
                        aryText(88) = "hudWpPerm=0;"
                        aryText(89) = "map=0;"
                        aryText(90) = "netStats=1;"
                        aryText(91) = "tracers=0;"
                        aryText(92) = "ultraAI=1;"
                        aryText(93) = "unlimitedSaves=0;"
                        aryText(94) = "vonID=0;"
                        aryText(95) = "weaponCursor=0;"
                        aryText(96) = "ExtendetInfoType=0;"
                        aryText(97) = "MineTag=0;"
                        aryText(98) = "};"
                        aryText(99) = "skillFriendly=1;"
                        aryText(100) = "precisionFriendly=1;"
                        aryText(101) = "skillEnemy=1;"
                        aryText(102) = "precisionEnemy=1;"
                        aryText(103) = "};"
                        aryText(104) = "class Mercenary"
                        aryText(105) = "{"
                        aryText(106) = "class Flags"
                        aryText(107) = "{"
                        aryText(108) = "3rdPersonView=0;"
                        aryText(109) = "armor=0;"
                        aryText(110) = "autoAim=0;"
                        aryText(111) = "autoGuideAT=0;"
                        aryText(112) = "autoSpot=0;"
                        aryText(113) = "cameraShake=1;"
                        aryText(114) = "clockIndicator=0;"
                        aryText(115) = "deathMessages=0;"
                        aryText(116) = "enemyTag=0;"
                        aryText(117) = "friendlyTag=0;"
                        aryText(118) = "hud=0;"
                        aryText(119) = "hudGroupInfo=0;"
                        aryText(120) = "hudPerm=0;"
                        aryText(121) = "hudWp=0;"
                        aryText(122) = "hudWpPerm=0;"
                        aryText(123) = "map=0;"
                        aryText(124) = "netStats=0;"
                        aryText(125) = "tracers=0;"
                        aryText(126) = "ultraAI=0;"
                        aryText(127) = "unlimitedSaves=0;"
                        aryText(128) = "vonID=0;"
                        aryText(129) = "weaponCursor=0;"
                        aryText(130) = "ExtendetInfoType=0;"
                        aryText(131) = "MineTag=0;"
                        aryText(132) = "};"
                        aryText(133) = "skillFriendly=1;"
                        aryText(134) = "precisionFriendly=1;"
                        aryText(135) = "skillEnemy=1;"
                        aryText(136) = "precisionEnemy=1;"
                        aryText(137) = "};"
                        aryText(138) = "};"
                        aryText(139) = "difficulty = ""regular"";"
                        Try
                            Using sw As New StreamWriter(variable)
                                For x = 0 To 139
                                    sw.WriteLine(aryText(x))
                                Next
                                sw.Close()
                            End Using
                        Catch ex As Exception

                        End Try
                      
                    Catch ex As Exception

                    End Try

                Case 2
                    Try
                        aryText(0) = "class Difficulties"
                        aryText(1) = "{"
                        aryText(2) = "class Recruit"
                        aryText(3) = "{"
                        aryText(4) = "class Flags"
                        aryText(5) = "{"
                        aryText(6) = "3rdPersonView=1;"
                        aryText(7) = "armor=1;"
                        aryText(8) = "autoAim=0;"
                        aryText(9) = "autoGuideAT=1;"
                        aryText(10) = "autoSpot=1;"
                        aryText(11) = "cameraShake=0;"
                        aryText(12) = "clockIndicator=1;"
                        aryText(13) = "deathMessages=1;"
                        aryText(14) = "enemyTag=0;"
                        aryText(15) = "friendlyTag=1;"
                        aryText(16) = "hud=1;"
                        aryText(17) = "hudGroupInfo=1"
                        aryText(18) = "hudPerm=1;"
                        aryText(19) = "hudWp=1;"
                        aryText(20) = "hudWpPerm=1;"
                        aryText(21) = "map=1;"
                        aryText(22) = "netStats=1;"
                        aryText(23) = "tracers=1;"
                        aryText(24) = "ultraAI=0;"
                        aryText(25) = "unlimitedSaves=1;"
                        aryText(26) = "vonID=1;"
                        aryText(27) = "weaponCursor=1;"
                        aryText(28) = "ExtendetInfoType=1;"
                        aryText(29) = "MineTag=1;"
                        aryText(30) = "};"
                        aryText(31) = "skillFriendly=" + TextBox52.Text & ";"
                        aryText(32) = "precisionFriendly=" + TextBox51.Text & ";"
                        aryText(33) = "skillEnemy=" + TextBox50.Text & ";"
                        aryText(34) = "precisionEnemy=" + TextBox49.Text & ";"
                        aryText(35) = "};"
                        aryText(36) = "class Regular"
                        aryText(37) = "{"
                        aryText(38) = "class Flags"
                        aryText(39) = "{"
                        aryText(40) = "3rdPersonView=1;"
                        aryText(41) = "armor=0;"
                        aryText(42) = "autoAim=0;"
                        aryText(43) = "autoGuideAT=0;"
                        aryText(44) = "autoSpot=0;"
                        aryText(45) = "cameraShake=1;"
                        aryText(46) = "clockIndicator=0;"
                        aryText(47) = "deathMessages=1;"
                        aryText(48) = "enemyTag=0;"
                        aryText(49) = "friendlyTag=0;"
                        aryText(50) = "hud=0;"
                        aryText(51) = "hudGroupInfo=0;"
                        aryText(52) = "hudPerm=0;"
                        aryText(53) = "hudWp=0;"
                        aryText(54) = "hudWpPerm=0"
                        aryText(55) = "map=0;"
                        aryText(56) = "netStats=1;"
                        aryText(57) = "tracers=0;"
                        aryText(58) = "ultraAI=1;"
                        aryText(59) = "unlimitedSaves=0;"
                        aryText(60) = "vonID=0;"
                        aryText(61) = "weaponCursor=0;"
                        aryText(62) = "ExtendetInfoType=0;"
                        aryText(63) = "MineTag=0;"
                        aryText(64) = "};"
                        aryText(65) = "skillFriendly=" + TextBox52.Text & ";"
                        aryText(66) = "precisionFriendly=" + TextBox51.Text & ";"
                        aryText(67) = "skillEnemy=" + TextBox50.Text & ";"
                        aryText(68) = "precisionEnemy=" + TextBox49.Text & ";"
                        aryText(69) = "};"
                        aryText(70) = "class Veteran"
                        aryText(71) = "{"
                        aryText(72) = "class Flags"
                        aryText(73) = "{"
                        aryText(74) = "3rdPersonView=1;"
                        aryText(75) = "armor=0;"
                        aryText(76) = "autoAim=0;"
                        aryText(77) = "autoGuideAT=0;"
                        aryText(78) = "autoSpot=0;"
                        aryText(79) = "cameraShake=1;"
                        aryText(80) = "clockIndicator=0;"
                        aryText(81) = "deathMessages=1;"
                        aryText(82) = "enemyTag=0;"
                        aryText(83) = "friendlyTag=0;"
                        aryText(84) = "hud=0;"
                        aryText(85) = "hudGroupInfo=0;"
                        aryText(86) = "hudPerm=0;"
                        aryText(87) = "hudWp=0;"
                        aryText(88) = "hudWpPerm=0;"
                        aryText(89) = "map=0;"
                        aryText(90) = "netStats=1;"
                        aryText(91) = "tracers=0;"
                        aryText(92) = "ultraAI=1;"
                        aryText(93) = "unlimitedSaves=0;"
                        aryText(94) = "vonID=0;"
                        aryText(95) = "weaponCursor=0;"
                        aryText(96) = "ExtendetInfoType=0;"
                        aryText(97) = "MineTag=0;"
                        aryText(98) = "};"
                        aryText(99) = "skillFriendly=" + TextBox52.Text & ";"
                        aryText(100) = "precisionFriendly=" + TextBox51.Text & ";"
                        aryText(101) = "skillEnemy=" + TextBox50.Text & ";"
                        aryText(102) = "precisionEnemy=" + TextBox49.Text & ";"
                        aryText(103) = "};"
                        aryText(104) = "class Mercenary"
                        aryText(105) = "{"
                        aryText(106) = "class Flags"
                        aryText(107) = "{"
                        aryText(108) = "3rdPersonView=0;"
                        aryText(109) = "armor=0;"
                        aryText(110) = "autoAim=0;"
                        aryText(111) = "autoGuideAT=0;"
                        aryText(112) = "autoSpot=0;"
                        aryText(113) = "cameraShake=1;"
                        aryText(114) = "clockIndicator=0;"
                        aryText(115) = "deathMessages=0;"
                        aryText(116) = "enemyTag=0;"
                        aryText(117) = "friendlyTag=0;"
                        aryText(118) = "hud=0;"
                        aryText(119) = "hudGroupInfo=0;"
                        aryText(120) = "hudPerm=0;"
                        aryText(121) = "hudWp=0;"
                        aryText(122) = "hudWpPerm=0;"
                        aryText(123) = "map=0;"
                        aryText(124) = "netStats=0;"
                        aryText(125) = "tracers=0;"
                        aryText(126) = "ultraAI=0;"
                        aryText(127) = "unlimitedSaves=0;"
                        aryText(128) = "vonID=0;"
                        aryText(129) = "weaponCursor=0;"
                        aryText(130) = "ExtendetInfoType=0;"
                        aryText(131) = "MineTag=0;"
                        aryText(132) = "};"
                        aryText(133) = "skillFriendly=1;"
                        aryText(134) = "precisionFriendly=1;"
                        aryText(135) = "skillEnemy=1;"
                        aryText(136) = "precisionEnemy=1;"
                        aryText(137) = "};"
                        aryText(138) = "};"
                        aryText(139) = "difficulty = ""veteran"";"
                        Try
                            Using sw As New StreamWriter(variable)
                                For x = 0 To 139
                                    sw.WriteLine(aryText(x))
                                Next
                                sw.Close()
                            End Using
                        Catch ex As Exception

                        End Try
                       

                    Catch ex As Exception

                    End Try

                Case 3
                    Try
                        aryText(0) = "class Difficulties"
                        aryText(1) = "{"
                        aryText(2) = "class Recruit"
                        aryText(3) = "{"
                        aryText(4) = "class Flags"
                        aryText(5) = "{"
                        aryText(6) = "3rdPersonView=1;"
                        aryText(7) = "armor=1;"
                        aryText(8) = "autoAim=0;"
                        aryText(9) = "autoGuideAT=1;"
                        aryText(10) = "autoSpot=1;"
                        aryText(11) = "cameraShake=0;"
                        aryText(12) = "clockIndicator=1;"
                        aryText(13) = "deathMessages=1;"
                        aryText(14) = "enemyTag=0;"
                        aryText(15) = "friendlyTag=1;"
                        aryText(16) = "hud=1;"
                        aryText(17) = "hudGroupInfo=1"
                        aryText(18) = "hudPerm=1;"
                        aryText(19) = "hudWp=1;"
                        aryText(20) = "hudWpPerm=1;"
                        aryText(21) = "map=1;"
                        aryText(22) = "netStats=1;"
                        aryText(23) = "tracers=1;"
                        aryText(24) = "ultraAI=0;"
                        aryText(25) = "unlimitedSaves=1;"
                        aryText(26) = "vonID=1;"
                        aryText(27) = "weaponCursor=1;"
                        aryText(28) = "ExtendetInfoType=1;"
                        aryText(29) = "MineTag=1;"
                        aryText(30) = "};"
                        aryText(31) = "skillFriendly=" + TextBox52.Text & ";"
                        aryText(32) = "precisionFriendly=" + TextBox51.Text & ";"
                        aryText(33) = "skillEnemy=" + TextBox50.Text & ";"
                        aryText(34) = "precisionEnemy=" + TextBox49.Text & ";"
                        aryText(35) = "};"
                        aryText(36) = "class Regular"
                        aryText(37) = "{"
                        aryText(38) = "class Flags"
                        aryText(39) = "{"
                        aryText(40) = "3rdPersonView=1;"
                        aryText(41) = "armor=0;"
                        aryText(42) = "autoAim=0;"
                        aryText(43) = "autoGuideAT=0;"
                        aryText(44) = "autoSpot=0;"
                        aryText(45) = "cameraShake=1;"
                        aryText(46) = "clockIndicator=0;"
                        aryText(47) = "deathMessages=1;"
                        aryText(48) = "enemyTag=0;"
                        aryText(49) = "friendlyTag=0;"
                        aryText(50) = "hud=0;"
                        aryText(51) = "hudGroupInfo=0;"
                        aryText(52) = "hudPerm=0;"
                        aryText(53) = "hudWp=0;"
                        aryText(54) = "hudWpPerm=0"
                        aryText(55) = "map=0;"
                        aryText(56) = "netStats=1;"
                        aryText(57) = "tracers=0;"
                        aryText(58) = "ultraAI=1;"
                        aryText(59) = "unlimitedSaves=0;"
                        aryText(60) = "vonID=0;"
                        aryText(61) = "weaponCursor=0;"
                        aryText(62) = "ExtendetInfoType=0;"
                        aryText(63) = "MineTag=0;"
                        aryText(64) = "};"
                        aryText(65) = "skillFriendly=" + TextBox52.Text & ";"
                        aryText(66) = "precisionFriendly=" + TextBox51.Text & ";"
                        aryText(67) = "skillEnemy=" + TextBox50.Text & ";"
                        aryText(68) = "precisionEnemy=" + TextBox49.Text & ";"
                        aryText(69) = "};"
                        aryText(70) = "class Veteran"
                        aryText(71) = "{"
                        aryText(72) = "class Flags"
                        aryText(73) = "{"
                        aryText(74) = "3rdPersonView=1;"
                        aryText(75) = "armor=0;"
                        aryText(76) = "autoAim=0;"
                        aryText(77) = "autoGuideAT=0;"
                        aryText(78) = "autoSpot=0;"
                        aryText(79) = "cameraShake=1;"
                        aryText(80) = "clockIndicator=0;"
                        aryText(81) = "deathMessages=1;"
                        aryText(82) = "enemyTag=0;"
                        aryText(83) = "friendlyTag=0;"
                        aryText(84) = "hud=0;"
                        aryText(85) = "hudGroupInfo=0;"
                        aryText(86) = "hudPerm=0;"
                        aryText(87) = "hudWp=0;"
                        aryText(88) = "hudWpPerm=0;"
                        aryText(89) = "map=0;"
                        aryText(90) = "netStats=1;"
                        aryText(91) = "tracers=0;"
                        aryText(92) = "ultraAI=1;"
                        aryText(93) = "unlimitedSaves=0;"
                        aryText(94) = "vonID=0;"
                        aryText(95) = "weaponCursor=0;"
                        aryText(96) = "ExtendetInfoType=0;"
                        aryText(97) = "MineTag=0;"
                        aryText(98) = "};"
                        aryText(99) = "skillFriendly=" + TextBox52.Text & ";"
                        aryText(100) = "precisionFriendly=" + TextBox51.Text & ";"
                        aryText(101) = "skillEnemy=" + TextBox50.Text & ";"
                        aryText(102) = "precisionEnemy=" + TextBox49.Text & ";"
                        aryText(103) = "};"
                        aryText(104) = "class Mercenary"
                        aryText(105) = "{"
                        aryText(106) = "class Flags"
                        aryText(107) = "{"
                        aryText(108) = "3rdPersonView=0;"
                        aryText(109) = "armor=0;"
                        aryText(110) = "autoAim=0;"
                        aryText(111) = "autoGuideAT=0;"
                        aryText(112) = "autoSpot=0;"
                        aryText(113) = "cameraShake=1;"
                        aryText(114) = "clockIndicator=0;"
                        aryText(115) = "deathMessages=0;"
                        aryText(116) = "enemyTag=0;"
                        aryText(117) = "friendlyTag=0;"
                        aryText(118) = "hud=0;"
                        aryText(119) = "hudGroupInfo=0;"
                        aryText(120) = "hudPerm=0;"
                        aryText(121) = "hudWp=0;"
                        aryText(122) = "hudWpPerm=0;"
                        aryText(123) = "map=0;"
                        aryText(124) = "netStats=0;"
                        aryText(125) = "tracers=0;"
                        aryText(126) = "ultraAI=0;"
                        aryText(127) = "unlimitedSaves=0;"
                        aryText(128) = "vonID=0;"
                        aryText(129) = "weaponCursor=0;"
                        aryText(130) = "ExtendetInfoType=0;"
                        aryText(131) = "MineTag=0;"
                        aryText(132) = "};"
                        aryText(133) = "skillFriendly=" + TextBox52.Text & ";"
                        aryText(134) = "precisionFriendly=" + TextBox51.Text & ";"
                        aryText(135) = "skillEnemy=" + TextBox50.Text & ";"
                        aryText(136) = "precisionEnemy=" + TextBox49.Text & ";"
                        aryText(137) = "};"
                        aryText(138) = "};"
                        aryText(139) = "difficulty = ""mercenary"";"
                        Try
                            Using sw As New StreamWriter(variable)
                                For x = 0 To 139
                                    sw.WriteLine(aryText(x))
                                Next
                                sw.Close()
                            End Using
                        Catch ex As Exception

                        End Try
                       
                    Catch ex As Exception

                    End Try

            End Select
        Else

            MsgBox("Ha habido un problema y no ha podido realizarse el guardado")

        End If

        If System.IO.File.Exists(esusconfig) = True Then

            Dim i As Integer
            Dim aryText(48) As String
            aryText(0) = "steamPort = " + TextBox43.Text + ";"
            aryText(1) = "hostName = """ + TextBox48.Text + """;"
            aryText(2) = "password = """ + TextBox46.Text & """;"
            aryText(3) = "passwordAdmin = """ + TextBox47.Text & """;"
            If CheckBox8.Checked = True Then
                aryText(4) = "logFile  = """ + "logfile_consola.log" & """;"
            Else
            End If
            Try
                aryText(5) = "motd[] = {" + """" + TextBox42.Lines(0) + """" + ","
                aryText(6) = """" + TextBox42.Lines(1) + """" + ","
                aryText(7) = """" + TextBox42.Lines(2) + """" + ","
                aryText(8) = """" + TextBox42.Lines(3) + """" + ","
                aryText(9) = """" + TextBox42.Lines(4) + """" + ","
                aryText(10) = """" + TextBox42.Lines(5) + """" + ","
                aryText(11) = """" + TextBox42.Lines(6) + """" + ","
                aryText(12) = """" + TextBox42.Lines(7) + """" + ","
                aryText(13) = """" + TextBox42.Lines(8) + """" + ","
                aryText(14) = """" + TextBox42.Lines(9) + """" + ","
                aryText(15) = """" + TextBox42.Lines(10) + """" + ","
            Catch ex As Exception

            End Try

            aryText(16) = "};"
            aryText(17) = "motdInterval = " + NumericUpDown4.Text & ";"
            aryText(18) = ""
            aryText(19) = "maxPlayers =" & NumericUpDown3.Text & ";"
            Dim index = ComboBox4.SelectedIndex
            Select Case index
                Case 0
                    aryText(21) = "verifySignatures = 0;"
                Case 1
                    aryText(21) = "verifySignatures = 2;"
            End Select
            Dim index2 = ComboBox5.SelectedIndex
            Select Case index2
                Case 0
                    aryText(22) = "requiredSecureId = 0;"
                Case 1
                    aryText(22) = "requiredSecureId = 1;"
            End Select
            If CheckBox5.Checked = True Then
                aryText(23) = "kickduplicate = 1;"
            Else
                aryText(23) = "kickduplicate = 0;"
            End If
            aryText(24) = "voteMissionPlayers = " + NumericUpDown5.Text + ";"
            If CheckBox15.Checked = True Then
                aryText(25) = "disableVoN = 1;"
            Else
                aryText(25) = "disableVoN = 0;"
            End If
            If CheckBox15.Checked = True Then
                aryText(26) = "Headlessclients[]={" & TextBox62.Text & "};"
            Else
                aryText(26) = "Headlessclients[]={};"
            End If
            Dim porcentaje As String = Nothing
            Try
                Convert.ToDecimal(NumericUpDown6.Text)
                porcentaje = "0." + NumericUpDown6.Text
            Catch ex As Exception

            End Try
            aryText(27) = "voteThreshold = " + porcentaje & ";"
            aryText(28) = "vonCodecQuality = " + NumericUpDown7.Text & ";"
            If CheckBox4.Checked = True Then
                aryText(29) = "persistent = 1;"
            Else
                aryText(29) = "persistent = 0;"
            End If
            Dim index3 = ComboBox6.SelectedIndex
            Select Case index3
                Case 0
                    aryText(30) = "timeStampFormat = ""none"";"
                Case 1
                    aryText(30) = "timeStampFormat = ""short"";"
                Case 2
                    aryText(30) = "timeStampFormat = ""full"";"
            End Select
            If CheckBox6.Checked = True Then
                aryText(31) = "BattlEye = 1;"
            Else
                aryText(31) = "BattlEye = 0;"
            End If
            aryText(32) = "doubleIdDetected = " + TextBox39.Text + ";"
            aryText(33) = "onUserConnected = " + TextBox38.Text + ";"
            aryText(34) = "onUserDisconnected = " + TextBox37.Text + ";"
            aryText(35) = "onHackedData = " + TextBox36.Text + ";"
            aryText(36) = "onDifferentData = " + TextBox35.Text + ";"
            aryText(37) = "onUnsignedData = " + TextBox34.Text + ";"
            aryText(38) = "regularCheck = " + TextBox33.Text + ";"
            Dim index4 = ComboBox3.SelectedIndex
            Select Case index4
                Case 0
                    aryText(39) = "forceRotorLibSimulation = 0;"
                Case 1
                    aryText(39) = "forceRotorLibSimulation = 1;"
            End Select

            aryText(40) = "requiredBuild = " + TextBox21.Text + ";"
            aryText(41) = "class Missions"
            aryText(42) = "{"
            aryText(43) = "class Mission_1"
            aryText(44) = "{"


            Dim itemChecked As Object = Nothing
            For Each itemChecked In CheckedListBox2.CheckedItems
                itemChecked = itemChecked
            Next

            itemChecked = Replace(itemChecked, ".pbo", "")

            If itemChecked = Nothing Then
                aryText(45) = "template = """ + "&vacio&" & """;"
            Else

                aryText(45) = "template = """ + itemChecked.ToString & """;"

            End If


            Dim index5 = ComboBox7.SelectedIndex
            Select Case index5
                Case 0
                    aryText(46) = "difficulty = ""recruit"";"
                Case 1
                    aryText(46) = "difficulty = ""regular"";"
                Case 2
                    aryText(46) = "difficulty = ""veteran"";"
                Case 3
                    aryText(46) = "difficulty = ""mercenary"";"
            End Select
            aryText(47) = "};"
            aryText(48) = "};"
            Try
                Dim objWriter As New System.IO.StreamWriter(esusconfig)
                For i = 0 To 48
                    objWriter.WriteLine(aryText(i))
                Next
                objWriter.Close()
                objWriter.Dispose()
            Catch ex As Exception

            End Try
           
        Else
            MsgBox("Ha ocurrido un error el archivo no ha podido ser guardado")

        End If
        If System.IO.File.Exists(dificultad) = True Then


        Else
            MsgBox("Ha ocurrido un error el archivo no ha podido ser guardado")

        End If

        Try
            My.Computer.FileSystem.WriteAllText(puerto, TextBox45.Text, False)

        Catch ex As Exception

        End Try
        Dim sb As New System.Text.StringBuilder
        For Each itm As String In CheckedListBox1.CheckedItems
            sb.AppendLine(itm)
        Next
        If sb.ToString.Length >= 0 Then
            My.Computer.FileSystem.WriteAllText(mods, sb.ToString, False)
        End If
        Try
            Dim s As New IO.StreamWriter(prioridadmods)
            For i As Integer = 0 To ListBox1.Items.Count - 1
                s.Write(ListBox1.Items(i) & vbNewLine)
            Next
            s.Close()
        Catch ex As Exception

        End Try

        My.Settings.ram = TextBox5.Text
        My.Settings.cpu = TextBox16.Text
        My.Settings.extrahilos = TextBox17.Text
        My.Settings.cargarmision = CheckBox1.CheckState
        My.Settings.custom = TextBox2.Text
        My.Settings.Save()
        If MsgBox("¿Está seguro que desea guardar la configuración?", vbYesNo, "") = vbYes Then
            MsgBox("Datos Guardados")
        Else
        End If
    End Sub



    Private Sub Label31_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub Label27_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub Label34_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub Label30_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub Label35_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub Label33_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub Label32_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub TabPage6_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        Try
            VisordeLogs.Close()
            VisordeRpt.Close()
        Catch ex As Exception

        End Try
       
        If ComboBox1.SelectedItem <> "" Then
            TextBox20.Text = ComboBox1.SelectedItem
        End If
        perfilcambiante = esusservera3 & "\" & ComboBox1.SelectedItem.ToString
        carpetausercambiante = perfilcambiante & "\" & "Users"
        carpetausuariocambiante = carpetausercambiante & "\" & usuario
        puerto = Combine(perfilcambiante, txtpuerto)
        esusbasico = Combine(perfilcambiante, "Esus_basico.cfg")
        esusconfig = Combine(perfilcambiante, "Esus_config.cfg")
        dificultad = Combine(carpetausuariocambiante, usuario & ".Arma3Profile")
        variable = dificultad
        mods = Combine(perfilcambiante, addon)
        prioridadmods = Combine(perfilcambiante, prioridad)
        CheckedListBox1.Items.Clear()
        CheckedListBox3.Items.Clear()
        CheckedListBox2.Items.Clear()
        For Each folder In System.IO.Directory.GetDirectories(rutaarma, "@*")
            CheckedListBox1.Items.Add(Path.GetFileName(folder))
        Next
        For Each File In System.IO.Directory.GetFiles(mpmision, "*.pbo")
            CheckedListBox2.Items.Add(Path.GetFileName(File))
        Next
        For Each obj In CheckedListBox2.Items
            Dim entre As Integer = obj.IndexOf(".")
            Dim mapas As String = obj.Substring(entre + 1, obj.IndexOf(".", entre + 1) - entre - 1)
            ComboBox2.Items.Add(mapas)
        Next
        borrarmapasduplicados()
        TextBox68.Text = CheckedListBox1.Items.Count
        TextBox65.Text = CheckedListBox2.Items.Count
        TextBox67.Text = CheckedListBox1.CheckedItems.Count
        TextBox66.Text = CheckedListBox2.CheckedItems.Count
        ComboBox4.SelectedIndex = 0
        ComboBox5.SelectedIndex = 0
        ComboBox6.SelectedIndex = 0
        ComboBox3.SelectedIndex = 0
        ComboBox7.SelectedIndex = 0
        If CheckBox2.Checked = True Then
            Label22.Visible = False
            NumericUpDown7.Visible = False
        Else
            Label22.Visible = True
            NumericUpDown7.Visible = True
        End If
        Try
            Dim fileReader As System.IO.StreamReader
            fileReader = My.Computer.FileSystem.OpenTextFileReader(puerto)
            Dim stringReader As String
            stringReader = fileReader.ReadLine()
            TextBox45.Text = stringReader
            fileReader.Close()
        Catch ex As Exception
        End Try
        Call leermods()
        Call leerdificultad()
        Call leerperfilbasico()
        Call leerperfilconfig()
        TextBox43.Text = System.Text.RegularExpressions.Regex.Replace(TextBox43.Text, "\s{2,}", " ")
        TextBox39.Text = TextBox39.Text.Replace(" ", "")
        TextBox38.Text = TextBox38.Text.Replace(" ", "")
        TextBox37.Text = TextBox37.Text.Replace(" ", "")
        TextBox36.Text = TextBox36.Text.Replace(" ", "")
        TextBox35.Text = TextBox35.Text.Replace(" ", "")
        TextBox34.Text = TextBox34.Text.Replace(" ", "")
        TextBox33.Text = TextBox33.Text.Replace(" ", "")
        TextBox21.Text = TextBox21.Text.Replace(" ", "")
        TextBox7.Text = TextBox7.Text.Replace(" ", "")
        TextBox8.Text = TextBox8.Text.Replace(" ", "")
        TextBox9.Text = TextBox9.Text.Replace(" ", "")
        TextBox10.Text = TextBox10.Text.Replace(" ", "")
        TextBox11.Text = TextBox11.Text.Replace(" ", "")
        TextBox12.Text = TextBox12.Text.Replace(" ", "")
        TextBox13.Text = TextBox13.Text.Replace(" ", "")
        TextBox14.Text = TextBox14.Text.Replace(" ", "")
        TextBox15.Text = TextBox15.Text.Replace(" ", "")
        Call construirparametro()
        Call hc()
    End Sub

    Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click
        VisordeRpt.Show()
    End Sub

    Private Sub TabPage1_Click(sender As Object, e As EventArgs) Handles TabPage1.Click

    End Sub

    Private Sub Label12_Click(sender As Object, e As EventArgs)

    End Sub



    Private Sub Button29_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub Button29_Click_1(sender As Object, e As EventArgs)


    End Sub

    Private Sub Button30_Click(sender As Object, e As EventArgs) Handles Button30.Click

    End Sub

    Private Sub GroupBox12_Enter(sender As Object, e As EventArgs) Handles GroupBox12.Enter

    End Sub

    Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged
        If CheckBox2.Checked = True Then
            Label22.Visible = False
            NumericUpDown7.Visible = False
        Else
            Label22.Visible = True
            NumericUpDown7.Visible = True
        End If
    End Sub

    Private Sub Button27_Click(sender As Object, e As EventArgs) Handles Button27.Click
        Process.Start(rutaarma)
    End Sub

    Private Sub Button23_Click(sender As Object, e As EventArgs) Handles Button23.Click
        Process.Start(esusservera3)

    End Sub

    Private Sub TabPage8_Click(sender As Object, e As EventArgs) Handles TabPage8.Click

    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        core1 = PerformanceCounter1.NextValue
        ram = PerformanceCounter3.NextValue

    End Sub

    Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
        If ProgressBar1.Value < core1 Then
            ProgressBar1.Value += 1
        ElseIf ProgressBar1.Value > core1 Then
            ProgressBar1.Value -= 1
        End If
        If ProgressBar3.Value < ram Then
            ProgressBar3.Value += 1
        ElseIf ProgressBar3.Value > ram Then
            ProgressBar3.Value -= 1
        End If

        Label30.Text = ProgressBar1.Value.ToString + "%"
        Label60.Text = ProgressBar3.Value.ToString + "%"

    End Sub

    Private Sub TabPage3_Click(sender As Object, e As EventArgs) Handles TabPage3.Click

    End Sub

    Private Sub lanzarserver_Click(sender As Object, e As EventArgs) Handles lanzarserver.Click
        Call construirparametro()
        Process.Start(exearma3server, TextBox1.Text)
    End Sub

    Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click
        TextBox7.Text = "128"
        TextBox8.Text = "20"
        TextBox9.Text = "128"
        TextBox10.Text = "512"
        TextBox11.Text = "256"
        TextBox12.Text = "0,001"
        TextBox13.Text = "0,01"
        TextBox14.Text = "160"
        TextBox15.Text = "1400"
    End Sub

    Private Sub TabPage2_Click(sender As Object, e As EventArgs) Handles TabPage2.Click

    End Sub

    Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
        Try
            Clipboard.SetText(TextBox1.Text)
        Catch ex As Exception
            MessageBox.Show("No hay nada para copiar")
        End Try
    End Sub

    Private Sub Button28_Click(sender As Object, e As EventArgs) Handles Button28.Click
        Call leerperfilbasico()
    End Sub


    Private Sub ComboBox7_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox7.SelectedIndexChanged
        Dim treintayuno As String = Nothing
        Dim treintaydos As String = Nothing
        Dim treintaytres As String = Nothing
        Dim treintaycuatro As String = Nothing
        Dim cientrotreintaynueve As String = Nothing
        Dim index5 = ComboBox7.SelectedIndex
        Select Case index5
            Case 0
                treintayuno = System.IO.File.ReadAllLines(dificultad)(31)
                treintaydos = System.IO.File.ReadAllLines(dificultad)(32)
                treintaytres = System.IO.File.ReadAllLines(dificultad)(33)
                treintaycuatro = System.IO.File.ReadAllLines(dificultad)(34)
                cientrotreintaynueve = System.IO.File.ReadAllLines(dificultad)(139)
            Case 1
                treintayuno = System.IO.File.ReadAllLines(dificultad)(65)
                treintaydos = System.IO.File.ReadAllLines(dificultad)(66)
                treintaytres = System.IO.File.ReadAllLines(dificultad)(67)
                treintaycuatro = System.IO.File.ReadAllLines(dificultad)(68)
                cientrotreintaynueve = System.IO.File.ReadAllLines(dificultad)(139)
            Case 2
                treintayuno = System.IO.File.ReadAllLines(dificultad)(99)
                treintaydos = System.IO.File.ReadAllLines(dificultad)(100)
                treintaytres = System.IO.File.ReadAllLines(dificultad)(101)
                treintaycuatro = System.IO.File.ReadAllLines(dificultad)(102)
                cientrotreintaynueve = System.IO.File.ReadAllLines(dificultad)(139)
            Case 3
                treintayuno = System.IO.File.ReadAllLines(dificultad)(133)
                treintaydos = System.IO.File.ReadAllLines(dificultad)(134)
                treintaytres = System.IO.File.ReadAllLines(dificultad)(135)
                treintaycuatro = System.IO.File.ReadAllLines(dificultad)(136)
                cientrotreintaynueve = System.IO.File.ReadAllLines(dificultad)(139)
        End Select
        treintayuno = Replace(treintayuno, "skillFriendly=", "")
        treintayuno = Replace(treintayuno, ";", "")
        treintaydos = Replace(treintaydos, "precisionFriendly=", "")
        treintaydos = Replace(treintaydos, ";", "")
        treintaytres = Replace(treintaytres, "skillEnemy=", "")
        treintaytres = Replace(treintaytres, ";", "")
        treintaycuatro = Replace(treintaycuatro, "precisionEnemy=", "")
        treintaycuatro = Replace(treintaycuatro, ";", "")
        treintayuno = System.Text.RegularExpressions.Regex.Replace(treintayuno, "\s{2,}", " ")
        treintaydos = System.Text.RegularExpressions.Regex.Replace(treintaydos, "\s{2,}", " ")
        treintaytres = System.Text.RegularExpressions.Regex.Replace(treintaytres, "\s{2,}", " ")
        treintaycuatro = System.Text.RegularExpressions.Regex.Replace(treintaycuatro, "\s{2,}", " ")
        TextBox52.Text = treintayuno
        TextBox51.Text = treintaydos
        TextBox50.Text = treintaytres
        TextBox49.Text = treintaycuatro
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Dim texto As String
        If TextBox6.Text = Nothing Then
            texto = Nothing
            MsgBox("Escribe un nombre para el perfil")
        Else
            texto = TextBox6.Text
            perfilcambiante = esusservera3 & "\" & texto
            carpetausercambiante = perfilcambiante & "\" & "Users"
            carpetausuariocambiante = carpetausercambiante & "\" & usuario
            puerto = Combine(perfilcambiante, txtpuerto)
            esusbasico = Combine(perfilcambiante, "Esus_basico.cfg")
            esusconfig = Combine(perfilcambiante, "Esus_config.cfg")
            dificultad = Combine(carpetausuariocambiante, usuario & ".Arma3Profile")
            variable = dificultad
            mods = Combine(perfilcambiante, addon)
            prioridadmods = Combine(perfilcambiante, prioridad)
            System.IO.Directory.CreateDirectory(perfilcambiante)
            System.IO.Directory.CreateDirectory(carpetausercambiante)
            System.IO.Directory.CreateDirectory(carpetausuariocambiante)
            crearmod = File.Create(mods)
            crearmod.Close()
            crearmod.Dispose()
            crearprioridad = File.Create(prioridadmods)
            crearprioridad.Close()
            crearprioridad.Dispose()
            crearperfil = File.Create(esusbasico)
            crearperfil.Close()
            crearperfil.Dispose()
            puertost = System.IO.File.Create(puerto)
            puertost.Close()
            puertost.Dispose()
            creadordificultad = File.Create(dificultad)
            creadordificultad.Close()
            crearperfil2 = File.Create(esusconfig)
            crearperfil2.Close()
            crearperfil2.Dispose()
            ComboBox1.Items.Clear()
            Call creardificultad()
            For Each perfiles As String In My.Computer.FileSystem.GetDirectories _
      (esusservera3)
                ComboBox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension(perfiles))
            Next
            TextBox6.Text = Nothing
        End If
        ComboBox1.SelectedItem = "PorDefecto"
    End Sub

    Private Sub TabPage7_Click(sender As Object, e As EventArgs) Handles TabPage7.Click

    End Sub

    Private Sub Button31_Click(sender As Object, e As EventArgs) Handles Button31.Click
        Dim borrado As String = Nothing
        If TextBox20.Text = Nothing Then
        ElseIf TextBox20.Text = "PorDefecto" Then
            MsgBox("Este es el perfil por defecto no puedes borrarlo!!")
        Else
            borrado = esusservera3 & "\" & TextBox20.Text
            Try
                My.Computer.FileSystem.DeleteDirectory(borrado, FileIO.UIOption.AllDialogs, FileIO.RecycleOption.SendToRecycleBin)
                ComboBox1.Items.Clear()
                For Each perfiles As String In My.Computer.FileSystem.GetDirectories _
     (esusservera3)
                    ComboBox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension(perfiles))
                Next
                TextBox20.Text = Nothing
            Catch ex As Exception
            End Try
        End If
        ComboBox1.SelectedItem = "PorDefecto"
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim renombrar As String = Nothing
        If TextBox20.Text = Nothing Then
        ElseIf TextBox20.Text = "PorDefecto" Then
            MsgBox("Este es el perfil por defecto no puedes cambiarle el nombre!!")
        Else
            renombrar = esusservera3 & "\" & ComboBox1.SelectedItem.ToString
            Try
                My.Computer.FileSystem.RenameDirectory(renombrar, _
TextBox20.Text)
                ComboBox1.Items.Clear()
                For Each perfiles As String In My.Computer.FileSystem.GetDirectories _
     (esusservera3)
                    ComboBox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension(perfiles))
                Next
                TextBox20.Text = Nothing
            Catch ex As Exception
            End Try
        End If
        ComboBox1.SelectedItem = "PorDefecto"
    End Sub

    Private Sub Button24_Click(sender As Object, e As EventArgs) Handles Button24.Click
        Dim ORIGEN As String = esusservera3
        Dim CARPETA As String = ORIGEN.Remove(0, ORIGEN.LastIndexOf("\"))
        If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim DESTINO As String = FolderBrowserDialog1.SelectedPath & CARPETA
            If My.Computer.FileSystem.DirectoryExists(DESTINO) = False Then
                My.Computer.FileSystem.CreateDirectory(DESTINO)
            Else
                MessageBox.Show("Ya has exportado tu carpeta de perfiles al escritorio, por favor borrala para hacer otra copia.")
            End If
            Try
                My.Computer.FileSystem.CopyDirectory(ORIGEN, DESTINO)
            Catch ex As Exception
            End Try
        End If
    End Sub

    Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
        Visordelogs.Show()
    End Sub

    Private Sub TextBox45_TextChanged(sender As Object, e As EventArgs) Handles TextBox45.TextChanged
    End Sub

    Private Sub CheckBox15_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox15.CheckedChanged
        If CheckBox15.Checked = True Then
            TextBox60.Visible = True
            TextBox62.Visible = True
            TextBox63.Visible = True
            TextBox18.Visible = True
            TextBox61.Visible = True
            Label64.Visible = True
            Label65.Visible = True
            Label66.Visible = True
            Label67.Visible = True
            Label84.Visible = True
            CheckBox3.Checked = True
        Else
            TextBox60.Visible = False
            TextBox62.Visible = False
            TextBox63.Visible = False
            TextBox18.Visible = False
            TextBox61.Visible = False
            Label64.Visible = False
            Label65.Visible = False
            Label66.Visible = False
            Label67.Visible = False
            Label84.Visible = False
            CheckBox3.Checked = False

        End If
    End Sub

    Private Sub TabPage5_Click(sender As Object, e As EventArgs) Handles TabPage5.Click

    End Sub

    Private Sub Button22_Click(sender As Object, e As EventArgs) Handles Button22.Click
        Call hc()
        Process.Start(exearma3, TextBox19.Text)
    End Sub
  
    Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.CheckedChanged
        If CheckBox3.Checked = True Then
            TextBox60.Enabled = False
            TextBox62.Enabled = False
            TextBox63.Enabled = False
            TextBox18.Enabled = False
            TextBox61.Enabled = False
            Call hc()
        Else
            TextBox60.Enabled = True
            TextBox62.Enabled = True
            TextBox63.Enabled = True
            TextBox18.Enabled = True
            TextBox61.Enabled = True
        End If
    End Sub

    Private Sub TextBox42_TextChanged(sender As Object, e As EventArgs) Handles TextBox42.TextChanged
        Dim A$, I&
        A = TextBox42.Text
        Do
            I = Len(A)
            A = Replace(A, vbCrLf & vbCrLf, vbCrLf)
        Loop While Len(A) <> I
        TextBox42.Text = A
    End Sub
    Private Sub TextBox42_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox42.KeyPress
        If (TextBox42.Lines.Length + 1 > 10) And AscW(e.KeyChar) = Keys.Enter Then
            e.KeyChar = String.Empty
            MsgBox("Has llegado al limite máximo que puedes escribir!")
        End If
    End Sub
End Class

